/*
 * AnaliseAcidenteTrabalho.java
 *
 * Created on September 28, 2007, 3:56 PM
 * Copyright lluis
 */
package analiseacidentestrabalho;

import com.sun.data.provider.RowKey;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.rave.web.ui.component.Body;
import com.sun.rave.web.ui.component.Button;
import com.sun.rave.web.ui.component.Checkbox;
import com.sun.rave.web.ui.component.DropDown;
import com.sun.rave.web.ui.component.Form;
import com.sun.rave.web.ui.component.Head;
import com.sun.rave.web.ui.component.HiddenField;
import com.sun.rave.web.ui.component.Html;
import com.sun.rave.web.ui.component.Hyperlink;
import com.sun.rave.web.ui.component.ImageComponent;
import com.sun.rave.web.ui.component.ImageHyperlink;
import com.sun.rave.web.ui.component.Link;
import com.sun.rave.web.ui.component.Page;
import com.sun.rave.web.ui.component.PanelGroup;
import com.sun.rave.web.ui.component.RadioButton;
import com.sun.rave.web.ui.component.StaticText;
import com.sun.rave.web.ui.component.Table;
import com.sun.rave.web.ui.component.TableColumn;
import com.sun.rave.web.ui.component.TableRowGroup;
import com.sun.rave.web.ui.component.TextArea;
import com.sun.rave.web.ui.component.TextField;
import com.sun.rave.web.ui.model.DefaultTableDataProvider;
import com.sun.rave.web.ui.model.SingleSelectOptionsList;
import db.AnalisesDataProvider;
import db.TrabalhadoresListDataProvider;
import db.UtilizadoresDataProvider;
import global.Global;
import java.io.File;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.ListIterator;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
import javax.faces.application.ApplicationFactory;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.el.MethodBinding;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.mail.Authenticator;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.*;   
import javax.mail.util.ByteArrayDataSource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import pagestate.AnaliseAcidenteTrabalhoState;
import pdf.Pdf;
import pdf.PdfGenerator;
import utils.Utils;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 */
public class AnaliseAcidenteTrabalho extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
    private int __placeholder;
    
    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
    }
    
    private Page page1 = new Page();
    
    public Page getPage1() {
        return page1;
    }
    
    public void setPage1(Page p) {
        this.page1 = p;
    }
    
    private Html html1 = new Html();
    
    public Html getHtml1() {
        return html1;
    }
    
    public void setHtml1(Html h) {
        this.html1 = h;
    }
    
    private Head head1 = new Head();
    
    public Head getHead1() {
        return head1;
    }
    
    public void setHead1(Head h) {
        this.head1 = h;
    }
    
    private Link link1 = new Link();
    
    public Link getLink1() {
        return link1;
    }
    
    public void setLink1(Link l) {
        this.link1 = l;
    }
    
    private Body body1 = new Body();
    
    public Body getBody1() {
        return body1;
    }
    
    public void setBody1(Body b) {
        this.body1 = b;
    }
    
    private Form form1 = new Form();
    
    public Form getForm1() {
        return form1;
    }
    
    public void setForm1(Form f) {
        this.form1 = f;
    }

    private HtmlPanelGrid gridBase1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridBase1() {
        return gridBase1;
    }

    public void setGridBase1(HtmlPanelGrid hpg) {
        this.gridBase1 = hpg;
    }

    private HtmlPanelGrid gridLayout1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridLayout1() {
        return gridLayout1;
    }

    public void setGridLayout1(HtmlPanelGrid hpg) {
        this.gridLayout1 = hpg;
    }

    private HtmlPanelGrid gridMsg = new HtmlPanelGrid();

    public HtmlPanelGrid getGridMsg() {
        return gridMsg;
    }

    public void setGridMsg(HtmlPanelGrid hpg) {
        this.gridMsg = hpg;
    }

    private StaticText txtMsg = new StaticText();

    public StaticText getTxtMsg() {
        return txtMsg;
    }

    public void setTxtMsg(StaticText st) {
        this.txtMsg = st;
    }

    private HtmlPanelGrid gridCabecalho = new HtmlPanelGrid();

    public HtmlPanelGrid getGridCabecalho() {
        return gridCabecalho;
    }

    public void setGridCabecalho(HtmlPanelGrid hpg) {
        this.gridCabecalho = hpg;
    }

    private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel2() {
        return gridPanel2;
    }

    public void setGridPanel2(HtmlPanelGrid hpg) {
        this.gridPanel2 = hpg;
    }

    private StaticText lblEmpresa1 = new StaticText();

    public StaticText getLblEmpresa1() {
        return lblEmpresa1;
    }

    public void setLblEmpresa1(StaticText st) {
        this.lblEmpresa1 = st;
    }

    private StaticText txtEmpresa = new StaticText();

    public StaticText getTxtEmpresa() {
        return txtEmpresa;
    }

    public void setTxtEmpresa(StaticText st) {
        this.txtEmpresa = st;
    }

    private StaticText staticText4 = new StaticText();

    public StaticText getStaticText4() {
        return staticText4;
    }

    public void setStaticText4(StaticText st) {
        this.staticText4 = st;
    }

    private StaticText txtEstabelecimento = new StaticText();

    public StaticText getTxtEstabelecimento() {
        return txtEstabelecimento;
    }

    public void setTxtEstabelecimento(StaticText st) {
        this.txtEstabelecimento = st;
    }

    private StaticText txtTrabalhador = new StaticText();

    public StaticText getTxtTrabalhador() {
        return txtTrabalhador;
    }

    public void setTxtTrabalhador(StaticText st) {
        this.txtTrabalhador = st;
    }

    private HtmlPanelGrid gridTrabalhadores = new HtmlPanelGrid();

    public HtmlPanelGrid getGridTrabalhadores() {
        return gridTrabalhadores;
    }

    public void setGridTrabalhadores(HtmlPanelGrid hpg) {
        this.gridTrabalhadores = hpg;
    }

    private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel3() {
        return gridPanel3;
    }

    public void setGridPanel3(HtmlPanelGrid hpg) {
        this.gridPanel3 = hpg;
    }

    private StaticText staticText5 = new StaticText();

    public StaticText getStaticText5() {
        return staticText5;
    }

    public void setStaticText5(StaticText st) {
        this.staticText5 = st;
    }

    private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel4() {
        return gridPanel4;
    }

    public void setGridPanel4(HtmlPanelGrid hpg) {
        this.gridPanel4 = hpg;
    }

    private StaticText txtSearchMsg = new StaticText();

    public StaticText getTxtSearchMsg() {
        return txtSearchMsg;
    }

    public void setTxtSearchMsg(StaticText st) {
        this.txtSearchMsg = st;
    }

    private HtmlPanelGrid gridSiprp = new HtmlPanelGrid();

    public HtmlPanelGrid getGridSiprp() {
        return gridSiprp;
    }

    public void setGridSiprp(HtmlPanelGrid hpg) {
        this.gridSiprp = hpg;
    }

    private HtmlPanelGrid gridPanel5 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel5() {
        return gridPanel5;
    }

    public void setGridPanel5(HtmlPanelGrid hpg) {
        this.gridPanel5 = hpg;
    }

    private StaticText staticText6 = new StaticText();

    public StaticText getStaticText6() {
        return staticText6;
    }

    public void setStaticText6(StaticText st) {
        this.staticText6 = st;
    }

    private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel6() {
        return gridPanel6;
    }

    public void setGridPanel6(HtmlPanelGrid hpg) {
        this.gridPanel6 = hpg;
    }

    private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel7() {
        return gridPanel7;
    }

    public void setGridPanel7(HtmlPanelGrid hpg) {
        this.gridPanel7 = hpg;
    }

    private StaticText staticText9 = new StaticText();

    public StaticText getStaticText9() {
        return staticText9;
    }

    public void setStaticText9(StaticText st) {
        this.staticText9 = st;
    }

    private PanelGroup groupPanel3 = new PanelGroup();

    public PanelGroup getGroupPanel3() {
        return groupPanel3;
    }

    public void setGroupPanel3(PanelGroup pg) {
        this.groupPanel3 = pg;
    }

    private StaticText staticText10 = new StaticText();

    public StaticText getStaticText10() {
        return staticText10;
    }

    public void setStaticText10(StaticText st) {
        this.staticText10 = st;
    }

    private StaticText txtCap = new StaticText();

    public StaticText getTxtCap() {
        return txtCap;
    }

    public void setTxtCap(StaticText st) {
        this.txtCap = st;
    }
    
    // </editor-fold>
    //private String IMAGE_URL = "/resources/images";   
    
//    private final static int ESTADO_SEG = 1;
//    private final static int ESTADO_RH1 = 2;    
//    private final static int ESTADO_HS = 3;     
//    private final static int ESTADO_RH2 = 4;        
//    private final static int ESTADO_MEDICO = 5;            
//    private final static int ESTADO_ASSINATURAS = 6;        
//    private final static int ESTADO_IMPRESSAO = 7;        
//    private final static int ESTADO_FECHAR = 8;        
//    private final static int ESTADO_CONCLUIDO = 9;  
    
    
    private final static int ESTADO_ASSINATURA_1 = 1;            
    private final static int ESTADO_ASSINATURA_2 = 2;                
    private final static int ESTADO_ASSINATURA_3 = 3; 
    
//    private final static int ESTADO_ASSINATURA_RESP_SEG = 1;
//    private final static int ESTADO_ASSINATURA_SEG = 2;    
//    private final static int ESTADO_ASSINATURA_HS = 3;        
//    private final static int ESTADO_ASSINATURA_MED = 4;        
//    private final static int ESTADO_ASSINATURA_RH = 5;       
//    private final static int ESTADO_ASSINATURA_RESP_RH = 6;            
    
    private final static int IMAGE_WIDTH = 48;        
    private final static int IMAGE_HEIGHT = 48;     
    
    private static final String PDFS_FOLDER_URL = "/resources/pdfs";        

    private Hyperlink lnkLblTrabalhador = new Hyperlink();

    public Hyperlink getLnkLblTrabalhador() {
        return lnkLblTrabalhador;
    }

    public void setLnkLblTrabalhador(Hyperlink h) {
        this.lnkLblTrabalhador = h;
    }

    private HtmlPanelGrid gridAcidentado = new HtmlPanelGrid();

    public HtmlPanelGrid getGridAcidentado() {
        return gridAcidentado;
    }

    public void setGridAcidentado(HtmlPanelGrid hpg) {
        this.gridAcidentado = hpg;
    }

    private HtmlPanelGrid gridPanel23 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel23() {
        return gridPanel23;
    }

    public void setGridPanel23(HtmlPanelGrid hpg) {
        this.gridPanel23 = hpg;
    }

    private StaticText staticText29 = new StaticText();

    public StaticText getStaticText29() {
        return staticText29;
    }

    public void setStaticText29(StaticText st) {
        this.staticText29 = st;
    }

    private HtmlPanelGrid gridPanel24 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel24() {
        return gridPanel24;
    }

    public void setGridPanel24(HtmlPanelGrid hpg) {
        this.gridPanel24 = hpg;
    }

    private HtmlPanelGrid gridPanel25 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel25() {
        return gridPanel25;
    }

    public void setGridPanel25(HtmlPanelGrid hpg) {
        this.gridPanel25 = hpg;
    }

    private StaticText staticText30 = new StaticText();

    public StaticText getStaticText30() {
        return staticText30;
    }

    public void setStaticText30(StaticText st) {
        this.staticText30 = st;
    }

    private StaticText txtNomeAcidentado = new StaticText();

    public StaticText getTxtNomeAcidentado() {
        return txtNomeAcidentado;
    }

    public void setTxtNomeAcidentado(StaticText st) {
        this.txtNomeAcidentado = st;
    }

    private StaticText staticText31 = new StaticText();

    public StaticText getStaticText31() {
        return staticText31;
    }

    public void setStaticText31(StaticText st) {
        this.staticText31 = st;
    }

    private StaticText txtDataNascimento = new StaticText();

    public StaticText getTxtDataNascimento() {
        return txtDataNascimento;
    }

    public void setTxtDataNascimento(StaticText st) {
        this.txtDataNascimento = st;
    }

    private StaticText staticText32 = new StaticText();

    public StaticText getStaticText32() {
        return staticText32;
    }

    public void setStaticText32(StaticText st) {
        this.staticText32 = st;
    }

    private TextField txtBI = new TextField();

    public TextField getTxtBI() {
        return txtBI;
    }

    public void setTxtBI(TextField tf) {
        this.txtBI = tf;
    }

    private StaticText staticText33 = new StaticText();

    public StaticText getStaticText33() {
        return staticText33;
    }

    public void setStaticText33(StaticText st) {
        this.staticText33 = st;
    }

    private TextField txtMorada = new TextField();

    public TextField getTxtMorada() {
        return txtMorada;
    }

    public void setTxtMorada(TextField tf) {
        this.txtMorada = tf;
    }

    private StaticText staticText34 = new StaticText();

    public StaticText getStaticText34() {
        return staticText34;
    }

    public void setStaticText34(StaticText st) {
        this.staticText34 = st;
    }

    private PanelGroup groupPanel6 = new PanelGroup();

    public PanelGroup getGroupPanel6() {
        return groupPanel6;
    }

    public void setGroupPanel6(PanelGroup pg) {
        this.groupPanel6 = pg;
    }

    private TextField txtCodPostal1 = new TextField();

    public TextField getTxtCodPostal1() {
        return txtCodPostal1;
    }

    public void setTxtCodPostal1(TextField tf) {
        this.txtCodPostal1 = tf;
    }

    private StaticText staticText35 = new StaticText();

    public StaticText getStaticText35() {
        return staticText35;
    }

    public void setStaticText35(StaticText st) {
        this.staticText35 = st;
    }

    private TextField txtCodPostal2 = new TextField();

    public TextField getTxtCodPostal2() {
        return txtCodPostal2;
    }

    public void setTxtCodPostal2(TextField tf) {
        this.txtCodPostal2 = tf;
    }

    private StaticText staticText36 = new StaticText();

    public StaticText getStaticText36() {
        return staticText36;
    }

    public void setStaticText36(StaticText st) {
        this.staticText36 = st;
    }

    private TextField txtLocalidade = new TextField();

    public TextField getTxtLocalidade() {
        return txtLocalidade;
    }

    public void setTxtLocalidade(TextField tf) {
        this.txtLocalidade = tf;
    }

    private StaticText staticText37 = new StaticText();

    public StaticText getStaticText37() {
        return staticText37;
    }

    public void setStaticText37(StaticText st) {
        this.staticText37 = st;
    }

    private TextField txtContactoTelefonico = new TextField();

    public TextField getTxtContactoTelefonico() {
        return txtContactoTelefonico;
    }

    public void setTxtContactoTelefonico(TextField tf) {
        this.txtContactoTelefonico = tf;
    }

    private StaticText staticText38 = new StaticText();

    public StaticText getStaticText38() {
        return staticText38;
    }

    public void setStaticText38(StaticText st) {
        this.staticText38 = st;
    }

    private StaticText stDataAdmissao = new StaticText();

    public StaticText getStDataAdmissao() {
        return stDataAdmissao;
    }

    public void setStDataAdmissao(StaticText st) {
        this.stDataAdmissao = st;
    }

    private StaticText staticText39 = new StaticText();

    public StaticText getStaticText39() {
        return staticText39;
    }

    public void setStaticText39(StaticText st) {
        this.staticText39 = st;
    }

    private StaticText stFuncao = new StaticText();

    public StaticText getStFuncao() {
        return stFuncao;
    }

    public void setStFuncao(StaticText st) {
        this.stFuncao = st;
    }

    private StaticText staticText40 = new StaticText();

    public StaticText getStaticText40() {
        return staticText40;
    }

    public void setStaticText40(StaticText st) {
        this.staticText40 = st;
    }

    private HtmlPanelGrid gridDadosAcidenteSeg = new HtmlPanelGrid();

    public HtmlPanelGrid getGridDadosAcidenteSeg() {
        return gridDadosAcidenteSeg;
    }

    public void setGridDadosAcidenteSeg(HtmlPanelGrid hpg) {
        this.gridDadosAcidenteSeg = hpg;
    }

    private HtmlPanelGrid gridPanel8 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel8() {
        return gridPanel8;
    }

    public void setGridPanel8(HtmlPanelGrid hpg) {
        this.gridPanel8 = hpg;
    }

    private StaticText staticText13 = new StaticText();

    public StaticText getStaticText13() {
        return staticText13;
    }

    public void setStaticText13(StaticText st) {
        this.staticText13 = st;
    }

    private HtmlPanelGrid gridPanel9 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel9() {
        return gridPanel9;
    }

    public void setGridPanel9(HtmlPanelGrid hpg) {
        this.gridPanel9 = hpg;
    }

    private HtmlPanelGrid gridPanel11 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel11() {
        return gridPanel11;
    }

    public void setGridPanel11(HtmlPanelGrid hpg) {
        this.gridPanel11 = hpg;
    }

    private PanelGroup groupPanel10 = new PanelGroup();

    public PanelGroup getGroupPanel10() {
        return groupPanel10;
    }

    public void setGroupPanel10(PanelGroup pg) {
        this.groupPanel10 = pg;
    }

    private StaticText staticText17 = new StaticText();

    public StaticText getStaticText17() {
        return staticText17;
    }

    public void setStaticText17(StaticText st) {
        this.staticText17 = st;
    }

    private PanelGroup groupPanel11 = new PanelGroup();

    public PanelGroup getGroupPanel11() {
        return groupPanel11;
    }

    public void setGroupPanel11(PanelGroup pg) {
        this.groupPanel11 = pg;
    }

    private StaticText staticText18 = new StaticText();

    public StaticText getStaticText18() {
        return staticText18;
    }

    public void setStaticText18(StaticText st) {
        this.staticText18 = st;
    }

    private TextField txtLocal = new TextField();

    public TextField getTxtLocal() {
        return txtLocal;
    }

    public void setTxtLocal(TextField tf) {
        this.txtLocal = tf;
    }

    private HtmlPanelGrid gridPanel12 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel12() {
        return gridPanel12;
    }

    public void setGridPanel12(HtmlPanelGrid hpg) {
        this.gridPanel12 = hpg;
    }

    private StaticText staticText19 = new StaticText();

    public StaticText getStaticText19() {
        return staticText19;
    }

    public void setStaticText19(StaticText st) {
        this.staticText19 = st;
    }

    private TextField txtTarefa = new TextField();

    public TextField getTxtTarefa() {
        return txtTarefa;
    }

    public void setTxtTarefa(TextField tf) {
        this.txtTarefa = tf;
    }

    private HtmlPanelGrid gridPanel13 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel13() {
        return gridPanel13;
    }

    public void setGridPanel13(HtmlPanelGrid hpg) {
        this.gridPanel13 = hpg;
    }

    private StaticText staticText20 = new StaticText();

    public StaticText getStaticText20() {
        return staticText20;
    }

    public void setStaticText20(StaticText st) {
        this.staticText20 = st;
    }

    private TextField txtSubstancias = new TextField();

    public TextField getTxtSubstancias() {
        return txtSubstancias;
    }

    public void setTxtSubstancias(TextField tf) {
        this.txtSubstancias = tf;
    }

    private HtmlPanelGrid gridPanel15 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel15() {
        return gridPanel15;
    }

    public void setGridPanel15(HtmlPanelGrid hpg) {
        this.gridPanel15 = hpg;
    }

    private StaticText staticText22 = new StaticText();

    public StaticText getStaticText22() {
        return staticText22;
    }

    public void setStaticText22(StaticText st) {
        this.staticText22 = st;
    }

    private TextField txtCondicoes = new TextField();

    public TextField getTxtCondicoes() {
        return txtCondicoes;
    }

    public void setTxtCondicoes(TextField tf) {
        this.txtCondicoes = tf;
    }

    private HtmlPanelGrid gridPanel16 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel16() {
        return gridPanel16;
    }

    public void setGridPanel16(HtmlPanelGrid hpg) {
        this.gridPanel16 = hpg;
    }

    private StaticText staticText23 = new StaticText();

    public StaticText getStaticText23() {
        return staticText23;
    }

    public void setStaticText23(StaticText st) {
        this.staticText23 = st;
    }

    private TextField txtTestemunhas = new TextField();

    public TextField getTxtTestemunhas() {
        return txtTestemunhas;
    }

    public void setTxtTestemunhas(TextField tf) {
        this.txtTestemunhas = tf;
    }

    private HtmlPanelGrid gridPanel17 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel17() {
        return gridPanel17;
    }

    public void setGridPanel17(HtmlPanelGrid hpg) {
        this.gridPanel17 = hpg;
    }

    private StaticText staticText24 = new StaticText();

    public StaticText getStaticText24() {
        return staticText24;
    }

    public void setStaticText24(StaticText st) {
        this.staticText24 = st;
    }

    private HtmlPanelGrid gridPanel18 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel18() {
        return gridPanel18;
    }

    public void setGridPanel18(HtmlPanelGrid hpg) {
        this.gridPanel18 = hpg;
    }

    private StaticText staticText25 = new StaticText();

    public StaticText getStaticText25() {
        return staticText25;
    }

    public void setStaticText25(StaticText st) {
        this.staticText25 = st;
    }

    private TextField txtDescricao = new TextField();

    public TextField getTxtDescricao() {
        return txtDescricao;
    }

    public void setTxtDescricao(TextField tf) {
        this.txtDescricao = tf;
    }

    private HtmlPanelGrid gridPanel19 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel19() {
        return gridPanel19;
    }

    public void setGridPanel19(HtmlPanelGrid hpg) {
        this.gridPanel19 = hpg;
    }

    private HtmlPanelGrid gridPanel20 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel20() {
        return gridPanel20;
    }

    public void setGridPanel20(HtmlPanelGrid hpg) {
        this.gridPanel20 = hpg;
    }

    private StaticText staticText26 = new StaticText();

    public StaticText getStaticText26() {
        return staticText26;
    }

    public void setStaticText26(StaticText st) {
        this.staticText26 = st;
    }

    private Button butImagem = new Button();

    public Button getButImagem() {
        return butImagem;
    }

    public void setButImagem(Button b) {
        this.butImagem = b;
    }

    private HtmlPanelGrid gridImages = new HtmlPanelGrid();

    public HtmlPanelGrid getGridImages() {
        return gridImages;
    }

    public void setGridImages(HtmlPanelGrid hpg) {
        this.gridImages = hpg;
    }

    private HtmlPanelGrid gridPanel21 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel21() {
        return gridPanel21;
    }

    public void setGridPanel21(HtmlPanelGrid hpg) {
        this.gridPanel21 = hpg;
    }

    private StaticText staticText27 = new StaticText();

    public StaticText getStaticText27() {
        return staticText27;
    }

    public void setStaticText27(StaticText st) {
        this.staticText27 = st;
    }

    private TextArea txtConclusoes = new TextArea();

    public TextArea getTxtConclusoes() {
        return txtConclusoes;
    }

    public void setTxtConclusoes(TextArea ta) {
        this.txtConclusoes = ta;
    }

    private HtmlPanelGrid gridPanel26 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel26() {
        return gridPanel26;
    }

    public void setGridPanel26(HtmlPanelGrid hpg) {
        this.gridPanel26 = hpg;
    }

    private StaticText staticText28 = new StaticText();

    public StaticText getStaticText28() {
        return staticText28;
    }

    public void setStaticText28(StaticText st) {
        this.staticText28 = st;
    }

    private TextArea txtAccoes = new TextArea();

    public TextArea getTxtAccoes() {
        return txtAccoes;
    }

    public void setTxtAccoes(TextArea ta) {
        this.txtAccoes = ta;
    }

    private HtmlPanelGrid gridDadosAcidenteRh = new HtmlPanelGrid();

    public HtmlPanelGrid getGridDadosAcidenteRh() {
        return gridDadosAcidenteRh;
    }

    public void setGridDadosAcidenteRh(HtmlPanelGrid hpg) {
        this.gridDadosAcidenteRh = hpg;
    }

    private HtmlPanelGrid gridPanel27 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel27() {
        return gridPanel27;
    }

    public void setGridPanel27(HtmlPanelGrid hpg) {
        this.gridPanel27 = hpg;
    }

    private StaticText staticText46 = new StaticText();

    public StaticText getStaticText46() {
        return staticText46;
    }

    public void setStaticText46(StaticText st) {
        this.staticText46 = st;
    }

    private HtmlPanelGrid gridPanel28 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel28() {
        return gridPanel28;
    }

    public void setGridPanel28(HtmlPanelGrid hpg) {
        this.gridPanel28 = hpg;
    }

    private HtmlPanelGrid gridPanel29 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel29() {
        return gridPanel29;
    }

    public void setGridPanel29(HtmlPanelGrid hpg) {
        this.gridPanel29 = hpg;
    }

    private StaticText staticText47 = new StaticText();

    public StaticText getStaticText47() {
        return staticText47;
    }

    public void setStaticText47(StaticText st) {
        this.staticText47 = st;
    }

    private HtmlPanelGrid gridPanel30 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel30() {
        return gridPanel30;
    }

    public void setGridPanel30(HtmlPanelGrid hpg) {
        this.gridPanel30 = hpg;
    }

    private StaticText staticText48 = new StaticText();

    public StaticText getStaticText48() {
        return staticText48;
    }

    public void setStaticText48(StaticText st) {
        this.staticText48 = st;
    }

    private HtmlPanelGrid gridPanel31 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel31() {
        return gridPanel31;
    }

    public void setGridPanel31(HtmlPanelGrid hpg) {
        this.gridPanel31 = hpg;
    }

    private RadioButton rbFormacaoSHSTY = new RadioButton();

    public RadioButton getRbFormacaoSHSTY() {
        return rbFormacaoSHSTY;
    }

    public void setRbFormacaoSHSTY(RadioButton rb) {
        this.rbFormacaoSHSTY = rb;
    }

    private StaticText staticText49 = new StaticText();

    public StaticText getStaticText49() {
        return staticText49;
    }

    public void setStaticText49(StaticText st) {
        this.staticText49 = st;
    }

    private HtmlPanelGrid gridPanel32 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel32() {
        return gridPanel32;
    }

    public void setGridPanel32(HtmlPanelGrid hpg) {
        this.gridPanel32 = hpg;
    }

    private StaticText staticText50 = new StaticText();

    public StaticText getStaticText50() {
        return staticText50;
    }

    public void setStaticText50(StaticText st) {
        this.staticText50 = st;
    }

    private HtmlPanelGrid gridPanel33 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel33() {
        return gridPanel33;
    }

    public void setGridPanel33(HtmlPanelGrid hpg) {
        this.gridPanel33 = hpg;
    }

    private RadioButton rbFormacaoSHSTN = new RadioButton();

    public RadioButton getRbFormacaoSHSTN() {
        return rbFormacaoSHSTN;
    }

    public void setRbFormacaoSHSTN(RadioButton rb) {
        this.rbFormacaoSHSTN = rb;
    }

    private StaticText stFormacaoDummy = new StaticText();

    public StaticText getStFormacaoDummy() {
        return stFormacaoDummy;
    }

    public void setStFormacaoDummy(StaticText st) {
        this.stFormacaoDummy = st;
    }

    private PanelGroup groupPanel12 = new PanelGroup();

    public PanelGroup getGroupPanel12() {
        return groupPanel12;
    }

    public void setGroupPanel12(PanelGroup pg) {
        this.groupPanel12 = pg;
    }

    private StaticText lblFormacaoSHSTNWhy = new StaticText();

    public StaticText getLblFormacaoSHSTNWhy() {
        return lblFormacaoSHSTNWhy;
    }

    public void setLblFormacaoSHSTNWhy(StaticText st) {
        this.lblFormacaoSHSTNWhy = st;
    }

    private TextField txtFormacaoSHSTNWhy = new TextField();

    public TextField getTxtFormacaoSHSTNWhy() {
        return txtFormacaoSHSTNWhy;
    }

    public void setTxtFormacaoSHSTNWhy(TextField tf) {
        this.txtFormacaoSHSTNWhy = tf;
    }

    private HtmlPanelGrid gridPanel34 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel34() {
        return gridPanel34;
    }

    public void setGridPanel34(HtmlPanelGrid hpg) {
        this.gridPanel34 = hpg;
    }

    private StaticText staticText53 = new StaticText();

    public StaticText getStaticText53() {
        return staticText53;
    }

    public void setStaticText53(StaticText st) {
        this.staticText53 = st;
    }

    private HtmlPanelGrid gridPanel35 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel35() {
        return gridPanel35;
    }

    public void setGridPanel35(HtmlPanelGrid hpg) {
        this.gridPanel35 = hpg;
    }

    private StaticText staticText54 = new StaticText();

    public StaticText getStaticText54() {
        return staticText54;
    }

    public void setStaticText54(StaticText st) {
        this.staticText54 = st;
    }

    private HtmlPanelGrid gridPanel36 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel36() {
        return gridPanel36;
    }

    public void setGridPanel36(HtmlPanelGrid hpg) {
        this.gridPanel36 = hpg;
    }

    private RadioButton rbAcidentesColaboradorY = new RadioButton();

    public RadioButton getRbAcidentesColaboradorY() {
        return rbAcidentesColaboradorY;
    }

    public void setRbAcidentesColaboradorY(RadioButton rb) {
        this.rbAcidentesColaboradorY = rb;
    }

    private StaticText staticText55 = new StaticText();

    public StaticText getStaticText55() {
        return staticText55;
    }

    public void setStaticText55(StaticText st) {
        this.staticText55 = st;
    }

    private PanelGroup groupPanel13 = new PanelGroup();

    public PanelGroup getGroupPanel13() {
        return groupPanel13;
    }

    public void setGroupPanel13(PanelGroup pg) {
        this.groupPanel13 = pg;
    }

    private StaticText staticText56 = new StaticText();

    public StaticText getStaticText56() {
        return staticText56;
    }

    public void setStaticText56(StaticText st) {
        this.staticText56 = st;
    }

    private TextField txtNrAcidentesColaborador = new TextField();

    public TextField getTxtNrAcidentesColaborador() {
        return txtNrAcidentesColaborador;
    }

    public void setTxtNrAcidentesColaborador(TextField tf) {
        this.txtNrAcidentesColaborador = tf;
    }

    private HtmlPanelGrid gridPanel37 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel37() {
        return gridPanel37;
    }

    public void setGridPanel37(HtmlPanelGrid hpg) {
        this.gridPanel37 = hpg;
    }

    private StaticText staticText57 = new StaticText();

    public StaticText getStaticText57() {
        return staticText57;
    }

    public void setStaticText57(StaticText st) {
        this.staticText57 = st;
    }

    private TextField txtNrRelatorioAcidentesColaborador1 = new TextField();

    public TextField getTxtNrRelatorioAcidentesColaborador1() {
        return txtNrRelatorioAcidentesColaborador1;
    }

    public void setTxtNrRelatorioAcidentesColaborador1(TextField tf) {
        this.txtNrRelatorioAcidentesColaborador1 = tf;
    }

    private TextField txtNrRelatorioAcidentesColaborador2 = new TextField();

    public TextField getTxtNrRelatorioAcidentesColaborador2() {
        return txtNrRelatorioAcidentesColaborador2;
    }

    public void setTxtNrRelatorioAcidentesColaborador2(TextField tf) {
        this.txtNrRelatorioAcidentesColaborador2 = tf;
    }

    private TextField txtNrRelatorioAcidentesColaborador3 = new TextField();

    public TextField getTxtNrRelatorioAcidentesColaborador3() {
        return txtNrRelatorioAcidentesColaborador3;
    }

    public void setTxtNrRelatorioAcidentesColaborador3(TextField tf) {
        this.txtNrRelatorioAcidentesColaborador3 = tf;
    }

    private TextField txtNrRelatorioAcidentesColaborador4 = new TextField();

    public TextField getTxtNrRelatorioAcidentesColaborador4() {
        return txtNrRelatorioAcidentesColaborador4;
    }

    public void setTxtNrRelatorioAcidentesColaborador4(TextField tf) {
        this.txtNrRelatorioAcidentesColaborador4 = tf;
    }

    private HtmlPanelGrid gridPanel38 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel38() {
        return gridPanel38;
    }

    public void setGridPanel38(HtmlPanelGrid hpg) {
        this.gridPanel38 = hpg;
    }

    private StaticText staticText58 = new StaticText();

    public StaticText getStaticText58() {
        return staticText58;
    }

    public void setStaticText58(StaticText st) {
        this.staticText58 = st;
    }

    private HtmlPanelGrid gridPanel39 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel39() {
        return gridPanel39;
    }

    public void setGridPanel39(HtmlPanelGrid hpg) {
        this.gridPanel39 = hpg;
    }

    private RadioButton rbAcidentesColaboradorN = new RadioButton();

    public RadioButton getRbAcidentesColaboradorN() {
        return rbAcidentesColaboradorN;
    }

    public void setRbAcidentesColaboradorN(RadioButton rb) {
        this.rbAcidentesColaboradorN = rb;
    }

    private StaticText staticText59 = new StaticText();

    public StaticText getStaticText59() {
        return staticText59;
    }

    public void setStaticText59(StaticText st) {
        this.staticText59 = st;
    }

    private HtmlPanelGrid gridPanel40 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel40() {
        return gridPanel40;
    }

    public void setGridPanel40(HtmlPanelGrid hpg) {
        this.gridPanel40 = hpg;
    }

    private StaticText staticText60 = new StaticText();

    public StaticText getStaticText60() {
        return staticText60;
    }

    public void setStaticText60(StaticText st) {
        this.staticText60 = st;
    }

    private HtmlPanelGrid gridPanel41 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel41() {
        return gridPanel41;
    }

    public void setGridPanel41(HtmlPanelGrid hpg) {
        this.gridPanel41 = hpg;
    }

    private StaticText staticText61 = new StaticText();

    public StaticText getStaticText61() {
        return staticText61;
    }

    public void setStaticText61(StaticText st) {
        this.staticText61 = st;
    }

    private HtmlPanelGrid gridPanel42 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel42() {
        return gridPanel42;
    }

    public void setGridPanel42(HtmlPanelGrid hpg) {
        this.gridPanel42 = hpg;
    }

    private RadioButton rbAcidentesColaboradoresY = new RadioButton();

    public RadioButton getRbAcidentesColaboradoresY() {
        return rbAcidentesColaboradoresY;
    }

    public void setRbAcidentesColaboradoresY(RadioButton rb) {
        this.rbAcidentesColaboradoresY = rb;
    }

    private StaticText staticText62 = new StaticText();

    public StaticText getStaticText62() {
        return staticText62;
    }

    public void setStaticText62(StaticText st) {
        this.staticText62 = st;
    }

    private PanelGroup groupPanel14 = new PanelGroup();

    public PanelGroup getGroupPanel14() {
        return groupPanel14;
    }

    public void setGroupPanel14(PanelGroup pg) {
        this.groupPanel14 = pg;
    }

    private StaticText staticText63 = new StaticText();

    public StaticText getStaticText63() {
        return staticText63;
    }

    public void setStaticText63(StaticText st) {
        this.staticText63 = st;
    }

    private TextField txtNrAcidentesColaboradores = new TextField();

    public TextField getTxtNrAcidentesColaboradores() {
        return txtNrAcidentesColaboradores;
    }

    public void setTxtNrAcidentesColaboradores(TextField tf) {
        this.txtNrAcidentesColaboradores = tf;
    }

    private HtmlPanelGrid gridPanel43 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel43() {
        return gridPanel43;
    }

    public void setGridPanel43(HtmlPanelGrid hpg) {
        this.gridPanel43 = hpg;
    }

    private StaticText staticText64 = new StaticText();

    public StaticText getStaticText64() {
        return staticText64;
    }

    public void setStaticText64(StaticText st) {
        this.staticText64 = st;
    }

    private TextField txtNrRelatorioAcidentesColaboradores1 = new TextField();

    public TextField getTxtNrRelatorioAcidentesColaboradores1() {
        return txtNrRelatorioAcidentesColaboradores1;
    }

    public void setTxtNrRelatorioAcidentesColaboradores1(TextField tf) {
        this.txtNrRelatorioAcidentesColaboradores1 = tf;
    }

    private TextField txtNrRelatorioAcidentesColaboradores2 = new TextField();

    public TextField getTxtNrRelatorioAcidentesColaboradores2() {
        return txtNrRelatorioAcidentesColaboradores2;
    }

    public void setTxtNrRelatorioAcidentesColaboradores2(TextField tf) {
        this.txtNrRelatorioAcidentesColaboradores2 = tf;
    }

    private TextField txtNrRelatorioAcidentesColaboradores3 = new TextField();

    public TextField getTxtNrRelatorioAcidentesColaboradores3() {
        return txtNrRelatorioAcidentesColaboradores3;
    }

    public void setTxtNrRelatorioAcidentesColaboradores3(TextField tf) {
        this.txtNrRelatorioAcidentesColaboradores3 = tf;
    }

    private TextField txtNrRelatorioAcidentesColaboradores4 = new TextField();

    public TextField getTxtNrRelatorioAcidentesColaboradores4() {
        return txtNrRelatorioAcidentesColaboradores4;
    }

    public void setTxtNrRelatorioAcidentesColaboradores4(TextField tf) {
        this.txtNrRelatorioAcidentesColaboradores4 = tf;
    }

    private HtmlPanelGrid gridPanel44 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel44() {
        return gridPanel44;
    }

    public void setGridPanel44(HtmlPanelGrid hpg) {
        this.gridPanel44 = hpg;
    }

    private StaticText staticText65 = new StaticText();

    public StaticText getStaticText65() {
        return staticText65;
    }

    public void setStaticText65(StaticText st) {
        this.staticText65 = st;
    }

    private HtmlPanelGrid gridPanel45 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel45() {
        return gridPanel45;
    }

    public void setGridPanel45(HtmlPanelGrid hpg) {
        this.gridPanel45 = hpg;
    }

    private RadioButton rbAcidentesColaboradoresN = new RadioButton();

    public RadioButton getRbAcidentesColaboradoresN() {
        return rbAcidentesColaboradoresN;
    }

    public void setRbAcidentesColaboradoresN(RadioButton rb) {
        this.rbAcidentesColaboradoresN = rb;
    }

    private StaticText staticText66 = new StaticText();

    public StaticText getStaticText66() {
        return staticText66;
    }

    public void setStaticText66(StaticText st) {
        this.staticText66 = st;
    }

    private HtmlPanelGrid gridRecomendacoesHS = new HtmlPanelGrid();

    public HtmlPanelGrid getGridRecomendacoesHS() {
        return gridRecomendacoesHS;
    }

    public void setGridRecomendacoesHS(HtmlPanelGrid hpg) {
        this.gridRecomendacoesHS = hpg;
    }

    private HtmlPanelGrid gridPanel46 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel46() {
        return gridPanel46;
    }

    public void setGridPanel46(HtmlPanelGrid hpg) {
        this.gridPanel46 = hpg;
    }

    private StaticText staticText67 = new StaticText();

    public StaticText getStaticText67() {
        return staticText67;
    }

    public void setStaticText67(StaticText st) {
        this.staticText67 = st;
    }

    private HtmlPanelGrid gridRecomendacoes = new HtmlPanelGrid();

    public HtmlPanelGrid getGridRecomendacoes() {
        return gridRecomendacoes;
    }

    public void setGridRecomendacoes(HtmlPanelGrid hpg) {
        this.gridRecomendacoes = hpg;
    }

    private HtmlPanelGrid gridPanel48 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel48() {
        return gridPanel48;
    }

    public void setGridPanel48(HtmlPanelGrid hpg) {
        this.gridPanel48 = hpg;
    }

    private StaticText stNrRecomendacao1 = new StaticText();

    public StaticText getStNrRecomendacao1() {
        return stNrRecomendacao1;
    }

    public void setStNrRecomendacao1(StaticText st) {
        this.stNrRecomendacao1 = st;
    }

    private ImageHyperlink lnkMoreRec1 = new ImageHyperlink();

    public ImageHyperlink getLnkMoreRec1() {
        return lnkMoreRec1;
    }

    public void setLnkMoreRec1(ImageHyperlink ih) {
        this.lnkMoreRec1 = ih;
    }
    
    private Hyperlink lnkDelImageTmp = new Hyperlink();

    public Hyperlink getLnkDelImageTmp() {
        return lnkDelImageTmp;
    }

    public void setLnkDelImageTmp(Hyperlink lnkDelImageTmp) {
        this.lnkDelImageTmp = lnkDelImageTmp;
    }    

    private HtmlPanelGrid gridSiprpView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridSiprpView() {
        return gridSiprpView;
    }

    public void setGridSiprpView(HtmlPanelGrid hpg) {
        this.gridSiprpView = hpg;
    }

    private HtmlPanelGrid gridPanel49 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel49() {
        return gridPanel49;
    }

    public void setGridPanel49(HtmlPanelGrid hpg) {
        this.gridPanel49 = hpg;
    }

    private StaticText staticText69 = new StaticText();

    public StaticText getStaticText69() {
        return staticText69;
    }

    public void setStaticText69(StaticText st) {
        this.staticText69 = st;
    }

    private HtmlPanelGrid gridPanel50 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel50() {
        return gridPanel50;
    }

    public void setGridPanel50(HtmlPanelGrid hpg) {
        this.gridPanel50 = hpg;
    }

    private HtmlPanelGrid gridPanel51 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel51() {
        return gridPanel51;
    }

    public void setGridPanel51(HtmlPanelGrid hpg) {
        this.gridPanel51 = hpg;
    }

    private HtmlPanelGrid gridAcidentadoView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridAcidentadoView() {
        return gridAcidentadoView;
    }

    public void setGridAcidentadoView(HtmlPanelGrid hpg) {
        this.gridAcidentadoView = hpg;
    }

    private HtmlPanelGrid gridPanel52 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel52() {
        return gridPanel52;
    }

    public void setGridPanel52(HtmlPanelGrid hpg) {
        this.gridPanel52 = hpg;
    }

    private StaticText staticText78 = new StaticText();

    public StaticText getStaticText78() {
        return staticText78;
    }

    public void setStaticText78(StaticText st) {
        this.staticText78 = st;
    }

    private HtmlPanelGrid gridPanel53 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel53() {
        return gridPanel53;
    }

    public void setGridPanel53(HtmlPanelGrid hpg) {
        this.gridPanel53 = hpg;
    }

    private HtmlPanelGrid gridPanel54 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel54() {
        return gridPanel54;
    }

    public void setGridPanel54(HtmlPanelGrid hpg) {
        this.gridPanel54 = hpg;
    }

    private HtmlPanelGrid gridDadosAcidenteRhView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridDadosAcidenteRhView() {
        return gridDadosAcidenteRhView;
    }

    public void setGridDadosAcidenteRhView(HtmlPanelGrid hpg) {
        this.gridDadosAcidenteRhView = hpg;
    }

    private HtmlPanelGrid gridPanel55 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel55() {
        return gridPanel55;
    }

    public void setGridPanel55(HtmlPanelGrid hpg) {
        this.gridPanel55 = hpg;
    }

    private StaticText staticText88 = new StaticText();

    public StaticText getStaticText88() {
        return staticText88;
    }

    public void setStaticText88(StaticText st) {
        this.staticText88 = st;
    }

    private HtmlPanelGrid gridPanel56 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel56() {
        return gridPanel56;
    }

    public void setGridPanel56(HtmlPanelGrid hpg) {
        this.gridPanel56 = hpg;
    }

    private HtmlPanelGrid gridSHST = new HtmlPanelGrid();

    public HtmlPanelGrid getGridSHST() {
        return gridSHST;
    }

    public void setGridSHST(HtmlPanelGrid hpg) {
        this.gridSHST = hpg;
    }

    private HtmlPanelGrid gridColaborador = new HtmlPanelGrid();

    public HtmlPanelGrid getGridColaborador() {
        return gridColaborador;
    }

    public void setGridColaborador(HtmlPanelGrid hpg) {
        this.gridColaborador = hpg;
    }

    private HtmlPanelGrid gridColaboradores = new HtmlPanelGrid();

    public HtmlPanelGrid getGridColaboradores() {
        return gridColaboradores;
    }

    public void setGridColaboradores(HtmlPanelGrid hpg) {
        this.gridColaboradores = hpg;
    }

    private SingleSelectOptionsList drpHoursDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDrpHoursDefaultOptions() {
        return drpHoursDefaultOptions;
    }

    public void setDrpHoursDefaultOptions(SingleSelectOptionsList ssol) {
        this.drpHoursDefaultOptions = ssol;
    }

    private SingleSelectOptionsList drpMinutesDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDrpMinutesDefaultOptions() {
        return drpMinutesDefaultOptions;
    }

    public void setDrpMinutesDefaultOptions(SingleSelectOptionsList ssol) {
        this.drpMinutesDefaultOptions = ssol;
    }

    private TextArea txtRecomendacao1 = new TextArea();

    public TextArea getTxtRecomendacao1() {
        return txtRecomendacao1;
    }

    public void setTxtRecomendacao1(TextArea ta) {
        this.txtRecomendacao1 = ta;
    }

    private HtmlPanelGrid gridRecomendacoesViewHS = new HtmlPanelGrid();

    public HtmlPanelGrid getGridRecomendacoesViewHS() {
        return gridRecomendacoesViewHS;
    }

    public void setGridRecomendacoesViewHS(HtmlPanelGrid hpg) {
        this.gridRecomendacoesViewHS = hpg;
    }

    private HtmlPanelGrid gridPanel47 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel47() {
        return gridPanel47;
    }

    public void setGridPanel47(HtmlPanelGrid hpg) {
        this.gridPanel47 = hpg;
    }

    private StaticText staticText51 = new StaticText();

    public StaticText getStaticText51() {
        return staticText51;
    }

    public void setStaticText51(StaticText st) {
        this.staticText51 = st;
    }

    private HtmlPanelGrid gridRecomendacoesView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridRecomendacoesView() {
        return gridRecomendacoesView;
    }

    public void setGridRecomendacoesView(HtmlPanelGrid hpg) {
        this.gridRecomendacoesView = hpg;
    }

    private HtmlPanelGrid gridMedidasRH = new HtmlPanelGrid();

    public HtmlPanelGrid getGridMedidasRH() {
        return gridMedidasRH;
    }

    public void setGridMedidasRH(HtmlPanelGrid hpg) {
        this.gridMedidasRH = hpg;
    }

    private HtmlPanelGrid gridPanel57 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel57() {
        return gridPanel57;
    }

    public void setGridPanel57(HtmlPanelGrid hpg) {
        this.gridPanel57 = hpg;
    }

    private StaticText staticText68 = new StaticText();

    public StaticText getStaticText68() {
        return staticText68;
    }

    public void setStaticText68(StaticText st) {
        this.staticText68 = st;
    }

    private HtmlPanelGrid gridMedidas = new HtmlPanelGrid();

    public HtmlPanelGrid getGridMedidas() {
        return gridMedidas;
    }

    public void setGridMedidas(HtmlPanelGrid hpg) {
        this.gridMedidas = hpg;
    }

    private HtmlPanelGrid gridPanel58 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel58() {
        return gridPanel58;
    }

    public void setGridPanel58(HtmlPanelGrid hpg) {
        this.gridPanel58 = hpg;
    }

    private StaticText stNrMedida1 = new StaticText();

    public StaticText getStNrMedida1() {
        return stNrMedida1;
    }

    public void setStNrMedida1(StaticText st) {
        this.stNrMedida1 = st;
    }

    private TextArea txtMedida1 = new TextArea();

    public TextArea getTxtMedida1() {
        return txtMedida1;
    }

    public void setTxtMedida1(TextArea ta) {
        this.txtMedida1 = ta;
    }

    private ImageHyperlink lnkMoreMed1 = new ImageHyperlink();

    public ImageHyperlink getLnkMoreMed1() {
        return lnkMoreMed1;
    }

    public void setLnkMoreMed1(ImageHyperlink ih) {
        this.lnkMoreMed1 = ih;
    }

    private HtmlPanelGrid gridMedidasViewRH = new HtmlPanelGrid();

    public HtmlPanelGrid getGridMedidasViewRH() {
        return gridMedidasViewRH;
    }

    public void setGridMedidasViewRH(HtmlPanelGrid hpg) {
        this.gridMedidasViewRH = hpg;
    }

    private HtmlPanelGrid gridPanel59 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel59() {
        return gridPanel59;
    }

    public void setGridPanel59(HtmlPanelGrid hpg) {
        this.gridPanel59 = hpg;
    }

    private StaticText staticText89 = new StaticText();

    public StaticText getStaticText89() {
        return staticText89;
    }

    public void setStaticText89(StaticText st) {
        this.staticText89 = st;
    }

    private HtmlPanelGrid gridMedidasView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridMedidasView() {
        return gridMedidasView;
    }

    public void setGridMedidasView(HtmlPanelGrid hpg) {
        this.gridMedidasView = hpg;
    }

    private HtmlPanelGrid gridMedico = new HtmlPanelGrid();

    public HtmlPanelGrid getGridMedico() {
        return gridMedico;
    }

    public void setGridMedico(HtmlPanelGrid hpg) {
        this.gridMedico = hpg;
    }

    private HtmlPanelGrid gridPanel60 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel60() {
        return gridPanel60;
    }

    public void setGridPanel60(HtmlPanelGrid hpg) {
        this.gridPanel60 = hpg;
    }

    private StaticText staticText90 = new StaticText();

    public StaticText getStaticText90() {
        return staticText90;
    }

    public void setStaticText90(StaticText st) {
        this.staticText90 = st;
    }

    private HtmlPanelGrid gridLesao1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridLesao1() {
        return gridLesao1;
    }

    public void setGridLesao1(HtmlPanelGrid hpg) {
        this.gridLesao1 = hpg;
    }

    private StaticText staticText91 = new StaticText();

    public StaticText getStaticText91() {
        return staticText91;
    }

    public void setStaticText91(StaticText st) {
        this.staticText91 = st;
    }

    private HtmlPanelGrid gridPanel61 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel61() {
        return gridPanel61;
    }

    public void setGridPanel61(HtmlPanelGrid hpg) {
        this.gridPanel61 = hpg;
    }

    private PanelGroup groupPanel17 = new PanelGroup();

    public PanelGroup getGroupPanel17() {
        return groupPanel17;
    }

    public void setGroupPanel17(PanelGroup pg) {
        this.groupPanel17 = pg;
    }

    private Checkbox chkCabeca = new Checkbox();

    public Checkbox getChkCabeca() {
        return chkCabeca;
    }

    public void setChkCabeca(Checkbox c) {
        this.chkCabeca = c;
    }

    private StaticText staticText93 = new StaticText();

    public StaticText getStaticText93() {
        return staticText93;
    }

    public void setStaticText93(StaticText st) {
        this.staticText93 = st;
    }

    private PanelGroup groupPanel18 = new PanelGroup();

    public PanelGroup getGroupPanel18() {
        return groupPanel18;
    }

    public void setGroupPanel18(PanelGroup pg) {
        this.groupPanel18 = pg;
    }

    private Checkbox chkMembroSupDir = new Checkbox();

    public Checkbox getChkMembroSupDir() {
        return chkMembroSupDir;
    }

    public void setChkMembroSupDir(Checkbox c) {
        this.chkMembroSupDir = c;
    }

    private StaticText staticText94 = new StaticText();

    public StaticText getStaticText94() {
        return staticText94;
    }

    public void setStaticText94(StaticText st) {
        this.staticText94 = st;
    }

    private HtmlPanelGrid gridPanel62 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel62() {
        return gridPanel62;
    }

    public void setGridPanel62(HtmlPanelGrid hpg) {
        this.gridPanel62 = hpg;
    }

    private StaticText lblEspecif1 = new StaticText();

    public StaticText getLblEspecif1() {
        return lblEspecif1;
    }

    public void setLblEspecif1(StaticText st) {
        this.lblEspecif1 = st;
    }

    private TextField txtEspecif1 = new TextField();

    public TextField getTxtEspecif1() {
        return txtEspecif1;
    }

    public void setTxtEspecif1(TextField tf) {
        this.txtEspecif1 = tf;
    }

    private PanelGroup groupPanel19 = new PanelGroup();

    public PanelGroup getGroupPanel19() {
        return groupPanel19;
    }

    public void setGroupPanel19(PanelGroup pg) {
        this.groupPanel19 = pg;
    }

    private Checkbox chkPescoco = new Checkbox();

    public Checkbox getChkPescoco() {
        return chkPescoco;
    }

    public void setChkPescoco(Checkbox c) {
        this.chkPescoco = c;
    }

    private StaticText staticText96 = new StaticText();

    public StaticText getStaticText96() {
        return staticText96;
    }

    public void setStaticText96(StaticText st) {
        this.staticText96 = st;
    }

    private PanelGroup groupPanel20 = new PanelGroup();

    public PanelGroup getGroupPanel20() {
        return groupPanel20;
    }

    public void setGroupPanel20(PanelGroup pg) {
        this.groupPanel20 = pg;
    }

    private Checkbox chkMembroSupEsq = new Checkbox();

    public Checkbox getChkMembroSupEsq() {
        return chkMembroSupEsq;
    }

    public void setChkMembroSupEsq(Checkbox c) {
        this.chkMembroSupEsq = c;
    }

    private StaticText staticText97 = new StaticText();

    public StaticText getStaticText97() {
        return staticText97;
    }

    public void setStaticText97(StaticText st) {
        this.staticText97 = st;
    }

    private HtmlPanelGrid gridPanel63 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel63() {
        return gridPanel63;
    }

    public void setGridPanel63(HtmlPanelGrid hpg) {
        this.gridPanel63 = hpg;
    }

    private StaticText lblEspecif2 = new StaticText();

    public StaticText getLblEspecif2() {
        return lblEspecif2;
    }

    public void setLblEspecif2(StaticText st) {
        this.lblEspecif2 = st;
    }

    private TextField txtEspecif2 = new TextField();

    public TextField getTxtEspecif2() {
        return txtEspecif2;
    }

    public void setTxtEspecif2(TextField tf) {
        this.txtEspecif2 = tf;
    }

    private PanelGroup groupPanel21 = new PanelGroup();

    public PanelGroup getGroupPanel21() {
        return groupPanel21;
    }

    public void setGroupPanel21(PanelGroup pg) {
        this.groupPanel21 = pg;
    }

    private Checkbox chkTronco = new Checkbox();

    public Checkbox getChkTronco() {
        return chkTronco;
    }

    public void setChkTronco(Checkbox c) {
        this.chkTronco = c;
    }

    private StaticText staticText99 = new StaticText();

    public StaticText getStaticText99() {
        return staticText99;
    }

    public void setStaticText99(StaticText st) {
        this.staticText99 = st;
    }

    private PanelGroup groupPanel22 = new PanelGroup();

    public PanelGroup getGroupPanel22() {
        return groupPanel22;
    }

    public void setGroupPanel22(PanelGroup pg) {
        this.groupPanel22 = pg;
    }

    private Checkbox chkMembroInfDir = new Checkbox();

    public Checkbox getChkMembroInfDir() {
        return chkMembroInfDir;
    }

    public void setChkMembroInfDir(Checkbox c) {
        this.chkMembroInfDir = c;
    }

    private StaticText staticText100 = new StaticText();

    public StaticText getStaticText100() {
        return staticText100;
    }

    public void setStaticText100(StaticText st) {
        this.staticText100 = st;
    }

    private HtmlPanelGrid gridPanel64 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel64() {
        return gridPanel64;
    }

    public void setGridPanel64(HtmlPanelGrid hpg) {
        this.gridPanel64 = hpg;
    }

    private StaticText lblEspecif3 = new StaticText();

    public StaticText getLblEspecif3() {
        return lblEspecif3;
    }

    public void setLblEspecif3(StaticText st) {
        this.lblEspecif3 = st;
    }

    private TextField txtEspecif3 = new TextField();

    public TextField getTxtEspecif3() {
        return txtEspecif3;
    }

    public void setTxtEspecif3(TextField tf) {
        this.txtEspecif3 = tf;
    }

    private StaticText staticText102 = new StaticText();

    public StaticText getStaticText102() {
        return staticText102;
    }

    public void setStaticText102(StaticText st) {
        this.staticText102 = st;
    }

    private PanelGroup groupPanel23 = new PanelGroup();

    public PanelGroup getGroupPanel23() {
        return groupPanel23;
    }

    public void setGroupPanel23(PanelGroup pg) {
        this.groupPanel23 = pg;
    }

    private Checkbox chkMembroInfEsq = new Checkbox();

    public Checkbox getChkMembroInfEsq() {
        return chkMembroInfEsq;
    }

    public void setChkMembroInfEsq(Checkbox c) {
        this.chkMembroInfEsq = c;
    }

    private StaticText staticText103 = new StaticText();

    public StaticText getStaticText103() {
        return staticText103;
    }

    public void setStaticText103(StaticText st) {
        this.staticText103 = st;
    }

    private HtmlPanelGrid gridPanel65 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel65() {
        return gridPanel65;
    }

    public void setGridPanel65(HtmlPanelGrid hpg) {
        this.gridPanel65 = hpg;
    }

    private StaticText lblEspecif4 = new StaticText();

    public StaticText getLblEspecif4() {
        return lblEspecif4;
    }

    public void setLblEspecif4(StaticText st) {
        this.lblEspecif4 = st;
    }

    private TextField txtEspecif4 = new TextField();

    public TextField getTxtEspecif4() {
        return txtEspecif4;
    }

    public void setTxtEspecif4(TextField tf) {
        this.txtEspecif4 = tf;
    }

    private HtmlPanelGrid gridPanel66 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel66() {
        return gridPanel66;
    }

    public void setGridPanel66(HtmlPanelGrid hpg) {
        this.gridPanel66 = hpg;
    }

    private StaticText staticText105 = new StaticText();

    public StaticText getStaticText105() {
        return staticText105;
    }

    public void setStaticText105(StaticText st) {
        this.staticText105 = st;
    }

    private TextField txtTipoLesao = new TextField();

    public TextField getTxtTipoLesao() {
        return txtTipoLesao;
    }

    public void setTxtTipoLesao(TextField tf) {
        this.txtTipoLesao = tf;
    }

    private HtmlPanelGrid gridPanel67 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel67() {
        return gridPanel67;
    }

    public void setGridPanel67(HtmlPanelGrid hpg) {
        this.gridPanel67 = hpg;
    }

    private StaticText staticText106 = new StaticText();

    public StaticText getStaticText106() {
        return staticText106;
    }

    public void setStaticText106(StaticText st) {
        this.staticText106 = st;
    }

    private HtmlPanelGrid gridIncapacidade1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridIncapacidade1() {
        return gridIncapacidade1;
    }

    public void setGridIncapacidade1(HtmlPanelGrid hpg) {
        this.gridIncapacidade1 = hpg;
    }

    private HtmlPanelGrid gridPanel68 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel68() {
        return gridPanel68;
    }

    public void setGridPanel68(HtmlPanelGrid hpg) {
        this.gridPanel68 = hpg;
    }

    private PanelGroup groupPanel24 = new PanelGroup();

    public PanelGroup getGroupPanel24() {
        return groupPanel24;
    }

    public void setGroupPanel24(PanelGroup pg) {
        this.groupPanel24 = pg;
    }

    private StaticText staticText107 = new StaticText();

    public StaticText getStaticText107() {
        return staticText107;
    }

    public void setStaticText107(StaticText st) {
        this.staticText107 = st;
    }

    private RadioButton rbIncapacidadeNone = new RadioButton();

    public RadioButton getRbIncapacidadeNone() {
        return rbIncapacidadeNone;
    }

    public void setRbIncapacidadeNone(RadioButton rb) {
        this.rbIncapacidadeNone = rb;
    }

    private StaticText staticText108 = new StaticText();

    public StaticText getStaticText108() {
        return staticText108;
    }

    public void setStaticText108(StaticText st) {
        this.staticText108 = st;
    }

    private RadioButton rbIncapacidadeTemp = new RadioButton();

    public RadioButton getRbIncapacidadeTemp() {
        return rbIncapacidadeTemp;
    }

    public void setRbIncapacidadeTemp(RadioButton rb) {
        this.rbIncapacidadeTemp = rb;
    }

    private StaticText staticText109 = new StaticText();

    public StaticText getStaticText109() {
        return staticText109;
    }

    public void setStaticText109(StaticText st) {
        this.staticText109 = st;
    }

    private PanelGroup groupPanel25 = new PanelGroup();

    public PanelGroup getGroupPanel25() {
        return groupPanel25;
    }

    public void setGroupPanel25(PanelGroup pg) {
        this.groupPanel25 = pg;
    }

    private StaticText staticText110 = new StaticText();

    public StaticText getStaticText110() {
        return staticText110;
    }

    public void setStaticText110(StaticText st) {
        this.staticText110 = st;
    }

    private TextField txtCoefIncapacidade = new TextField();

    public TextField getTxtCoefIncapacidade() {
        return txtCoefIncapacidade;
    }

    public void setTxtCoefIncapacidade(TextField tf) {
        this.txtCoefIncapacidade = tf;
    }

    private StaticText staticText111 = new StaticText();

    public StaticText getStaticText111() {
        return staticText111;
    }

    public void setStaticText111(StaticText st) {
        this.staticText111 = st;
    }

    private HtmlPanelGrid gridPanel69 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel69() {
        return gridPanel69;
    }

    public void setGridPanel69(HtmlPanelGrid hpg) {
        this.gridPanel69 = hpg;
    }

    private StaticText staticText112 = new StaticText();

    public StaticText getStaticText112() {
        return staticText112;
    }

    public void setStaticText112(StaticText st) {
        this.staticText112 = st;
    }

    private com.sun.rave.web.ui.component.Calendar calAvaliacaoIncap = new com.sun.rave.web.ui.component.Calendar();

    public com.sun.rave.web.ui.component.Calendar getCalAvaliacaoIncap() {
        return calAvaliacaoIncap;
    }

    public void setCalAvaliacaoIncap(com.sun.rave.web.ui.component.Calendar c) {
        this.calAvaliacaoIncap = c;
    }

    private StaticText staticText113 = new StaticText();

    public StaticText getStaticText113() {
        return staticText113;
    }

    public void setStaticText113(StaticText st) {
        this.staticText113 = st;
    }

    private com.sun.rave.web.ui.component.Calendar calRevisaoIncap = new com.sun.rave.web.ui.component.Calendar();

    public com.sun.rave.web.ui.component.Calendar getCalRevisaoIncap() {
        return calRevisaoIncap;
    }

    public void setCalRevisaoIncap(com.sun.rave.web.ui.component.Calendar c) {
        this.calRevisaoIncap = c;
    }

    private HtmlPanelGrid gridPanel70 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel70() {
        return gridPanel70;
    }

    public void setGridPanel70(HtmlPanelGrid hpg) {
        this.gridPanel70 = hpg;
    }

    private StaticText staticText114 = new StaticText();

    public StaticText getStaticText114() {
        return staticText114;
    }

    public void setStaticText114(StaticText st) {
        this.staticText114 = st;
    }

    private com.sun.rave.web.ui.component.Calendar calPeridoIncapDe = new com.sun.rave.web.ui.component.Calendar();

    public com.sun.rave.web.ui.component.Calendar getCalPeridoIncapDe() {
        return calPeridoIncapDe;
    }

    public void setCalPeridoIncapDe(com.sun.rave.web.ui.component.Calendar c) {
        this.calPeridoIncapDe = c;
    }

    private StaticText staticText115 = new StaticText();

    public StaticText getStaticText115() {
        return staticText115;
    }

    public void setStaticText115(StaticText st) {
        this.staticText115 = st;
    }

    private com.sun.rave.web.ui.component.Calendar calPeriodoIncapA = new com.sun.rave.web.ui.component.Calendar();

    public com.sun.rave.web.ui.component.Calendar getCalPeriodoIncapA() {
        return calPeriodoIncapA;
    }

    public void setCalPeriodoIncapA(com.sun.rave.web.ui.component.Calendar c) {
        this.calPeriodoIncapA = c;
    }

    private HtmlPanelGrid gridPanel71 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel71() {
        return gridPanel71;
    }

    public void setGridPanel71(HtmlPanelGrid hpg) {
        this.gridPanel71 = hpg;
    }

    private StaticText staticText116 = new StaticText();

    public StaticText getStaticText116() {
        return staticText116;
    }

    public void setStaticText116(StaticText st) {
        this.staticText116 = st;
    }

    private HtmlPanelGrid gridRestricoes = new HtmlPanelGrid();

    public HtmlPanelGrid getGridRestricoes() {
        return gridRestricoes;
    }

    public void setGridRestricoes(HtmlPanelGrid hpg) {
        this.gridRestricoes = hpg;
    }

    private HtmlPanelGrid gridPanel72 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel72() {
        return gridPanel72;
    }

    public void setGridPanel72(HtmlPanelGrid hpg) {
        this.gridPanel72 = hpg;
    }

    private HtmlPanelGrid gridPanel73 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel73() {
        return gridPanel73;
    }

    public void setGridPanel73(HtmlPanelGrid hpg) {
        this.gridPanel73 = hpg;
    }

    private HtmlPanelGrid gridPanel74 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel74() {
        return gridPanel74;
    }

    public void setGridPanel74(HtmlPanelGrid hpg) {
        this.gridPanel74 = hpg;
    }

    private HtmlPanelGrid gridPanel75 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel75() {
        return gridPanel75;
    }

    public void setGridPanel75(HtmlPanelGrid hpg) {
        this.gridPanel75 = hpg;
    }

    private ImageComponent image3 = new ImageComponent();

    public ImageComponent getImage3() {
        return image3;
    }

    public void setImage3(ImageComponent ic) {
        this.image3 = ic;
    }

    private ImageComponent image4 = new ImageComponent();

    public ImageComponent getImage4() {
        return image4;
    }

    public void setImage4(ImageComponent ic) {
        this.image4 = ic;
    }

    private ImageComponent image5 = new ImageComponent();

    public ImageComponent getImage5() {
        return image5;
    }

    public void setImage5(ImageComponent ic) {
        this.image5 = ic;
    }

    private PanelGroup groupPanel26 = new PanelGroup();

    public PanelGroup getGroupPanel26() {
        return groupPanel26;
    }

    public void setGroupPanel26(PanelGroup pg) {
        this.groupPanel26 = pg;
    }

    private StaticText staticText117 = new StaticText();

    public StaticText getStaticText117() {
        return staticText117;
    }

    public void setStaticText117(StaticText st) {
        this.staticText117 = st;
    }

    private Checkbox chkImgFlexao = new Checkbox();

    public Checkbox getChkImgFlexao() {
        return chkImgFlexao;
    }

    public void setChkImgFlexao(Checkbox c) {
        this.chkImgFlexao = c;
    }

    private HtmlPanelGrid gridPanel76 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel76() {
        return gridPanel76;
    }

    public void setGridPanel76(HtmlPanelGrid hpg) {
        this.gridPanel76 = hpg;
    }

    private ImageComponent image6 = new ImageComponent();

    public ImageComponent getImage6() {
        return image6;
    }

    public void setImage6(ImageComponent ic) {
        this.image6 = ic;
    }

    private HtmlPanelGrid gridPanel77 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel77() {
        return gridPanel77;
    }

    public void setGridPanel77(HtmlPanelGrid hpg) {
        this.gridPanel77 = hpg;
    }

    private ImageComponent image7 = new ImageComponent();

    public ImageComponent getImage7() {
        return image7;
    }

    public void setImage7(ImageComponent ic) {
        this.image7 = ic;
    }

    private ImageComponent image8 = new ImageComponent();

    public ImageComponent getImage8() {
        return image8;
    }

    public void setImage8(ImageComponent ic) {
        this.image8 = ic;
    }

    private PanelGroup groupPanel27 = new PanelGroup();

    public PanelGroup getGroupPanel27() {
        return groupPanel27;
    }

    public void setGroupPanel27(PanelGroup pg) {
        this.groupPanel27 = pg;
    }

    private StaticText staticText118 = new StaticText();

    public StaticText getStaticText118() {
        return staticText118;
    }

    public void setStaticText118(StaticText st) {
        this.staticText118 = st;
    }

    private Checkbox chkImgExt1 = new Checkbox();

    public Checkbox getChkImgExt1() {
        return chkImgExt1;
    }

    public void setChkImgExt1(Checkbox c) {
        this.chkImgExt1 = c;
    }

    private PanelGroup groupPanel28 = new PanelGroup();

    public PanelGroup getGroupPanel28() {
        return groupPanel28;
    }

    public void setGroupPanel28(PanelGroup pg) {
        this.groupPanel28 = pg;
    }

    private StaticText staticText119 = new StaticText();

    public StaticText getStaticText119() {
        return staticText119;
    }

    public void setStaticText119(StaticText st) {
        this.staticText119 = st;
    }

    private Checkbox chkImgExt2 = new Checkbox();

    public Checkbox getChkImgExt2() {
        return chkImgExt2;
    }

    public void setChkImgExt2(Checkbox c) {
        this.chkImgExt2 = c;
    }

    private HtmlPanelGrid gridPanel78 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel78() {
        return gridPanel78;
    }

    public void setGridPanel78(HtmlPanelGrid hpg) {
        this.gridPanel78 = hpg;
    }

    private ImageComponent image9 = new ImageComponent();

    public ImageComponent getImage9() {
        return image9;
    }

    public void setImage9(ImageComponent ic) {
        this.image9 = ic;
    }

    private ImageComponent image10 = new ImageComponent();

    public ImageComponent getImage10() {
        return image10;
    }

    public void setImage10(ImageComponent ic) {
        this.image10 = ic;
    }

    private PanelGroup groupPanel29 = new PanelGroup();

    public PanelGroup getGroupPanel29() {
        return groupPanel29;
    }

    public void setGroupPanel29(PanelGroup pg) {
        this.groupPanel29 = pg;
    }

    private StaticText staticText120 = new StaticText();

    public StaticText getStaticText120() {
        return staticText120;
    }

    public void setStaticText120(StaticText st) {
        this.staticText120 = st;
    }

    private Checkbox chkImgCab2 = new Checkbox();

    public Checkbox getChkImgCab2() {
        return chkImgCab2;
    }

    public void setChkImgCab2(Checkbox c) {
        this.chkImgCab2 = c;
    }

    private PanelGroup groupPanel30 = new PanelGroup();

    public PanelGroup getGroupPanel30() {
        return groupPanel30;
    }

    public void setGroupPanel30(PanelGroup pg) {
        this.groupPanel30 = pg;
    }

    private StaticText staticText121 = new StaticText();

    public StaticText getStaticText121() {
        return staticText121;
    }

    public void setStaticText121(StaticText st) {
        this.staticText121 = st;
    }

    private Checkbox chkImgCab3 = new Checkbox();

    public Checkbox getChkImgCab3() {
        return chkImgCab3;
    }

    public void setChkImgCab3(Checkbox c) {
        this.chkImgCab3 = c;
    }

    private HtmlPanelGrid gridPanel79 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel79() {
        return gridPanel79;
    }

    public void setGridPanel79(HtmlPanelGrid hpg) {
        this.gridPanel79 = hpg;
    }

    private ImageComponent image12 = new ImageComponent();

    public ImageComponent getImage12() {
        return image12;
    }

    public void setImage12(ImageComponent ic) {
        this.image12 = ic;
    }

    private ImageComponent image13 = new ImageComponent();

    public ImageComponent getImage13() {
        return image13;
    }

    public void setImage13(ImageComponent ic) {
        this.image13 = ic;
    }

    private ImageComponent image14 = new ImageComponent();

    public ImageComponent getImage14() {
        return image14;
    }

    public void setImage14(ImageComponent ic) {
        this.image14 = ic;
    }

    private PanelGroup groupPanel31 = new PanelGroup();

    public PanelGroup getGroupPanel31() {
        return groupPanel31;
    }

    public void setGroupPanel31(PanelGroup pg) {
        this.groupPanel31 = pg;
    }

    private StaticText staticText122 = new StaticText();

    public StaticText getStaticText122() {
        return staticText122;
    }

    public void setStaticText122(StaticText st) {
        this.staticText122 = st;
    }

    private Checkbox chkImgMa2 = new Checkbox();

    public Checkbox getChkImgMa2() {
        return chkImgMa2;
    }

    public void setChkImgMa2(Checkbox c) {
        this.chkImgMa2 = c;
    }

    private PanelGroup groupPanel32 = new PanelGroup();

    public PanelGroup getGroupPanel32() {
        return groupPanel32;
    }

    public void setGroupPanel32(PanelGroup pg) {
        this.groupPanel32 = pg;
    }

    private StaticText staticText123 = new StaticText();

    public StaticText getStaticText123() {
        return staticText123;
    }

    public void setStaticText123(StaticText st) {
        this.staticText123 = st;
    }

    private Checkbox chkImgMa3 = new Checkbox();

    public Checkbox getChkImgMa3() {
        return chkImgMa3;
    }

    public void setChkImgMa3(Checkbox c) {
        this.chkImgMa3 = c;
    }

    private PanelGroup groupPanel33 = new PanelGroup();

    public PanelGroup getGroupPanel33() {
        return groupPanel33;
    }

    public void setGroupPanel33(PanelGroup pg) {
        this.groupPanel33 = pg;
    }

    private StaticText staticText124 = new StaticText();

    public StaticText getStaticText124() {
        return staticText124;
    }

    public void setStaticText124(StaticText st) {
        this.staticText124 = st;
    }

    private Checkbox chkImgMa5 = new Checkbox();

    public Checkbox getChkImgMa5() {
        return chkImgMa5;
    }

    public void setChkImgMa5(Checkbox c) {
        this.chkImgMa5 = c;
    }

    private PanelGroup groupPanel34 = new PanelGroup();

    public PanelGroup getGroupPanel34() {
        return groupPanel34;
    }

    public void setGroupPanel34(PanelGroup pg) {
        this.groupPanel34 = pg;
    }

    private StaticText staticText125 = new StaticText();

    public StaticText getStaticText125() {
        return staticText125;
    }

    public void setStaticText125(StaticText st) {
        this.staticText125 = st;
    }

    private Checkbox chkImgMa6 = new Checkbox();

    public Checkbox getChkImgMa6() {
        return chkImgMa6;
    }

    public void setChkImgMa6(Checkbox c) {
        this.chkImgMa6 = c;
    }

    private HtmlPanelGrid gridPanel80 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel80() {
        return gridPanel80;
    }

    public void setGridPanel80(HtmlPanelGrid hpg) {
        this.gridPanel80 = hpg;
    }

    private ImageComponent image15 = new ImageComponent();

    public ImageComponent getImage15() {
        return image15;
    }

    public void setImage15(ImageComponent ic) {
        this.image15 = ic;
    }

    private ImageComponent image16 = new ImageComponent();

    public ImageComponent getImage16() {
        return image16;
    }

    public void setImage16(ImageComponent ic) {
        this.image16 = ic;
    }

    private PanelGroup groupPanel35 = new PanelGroup();

    public PanelGroup getGroupPanel35() {
        return groupPanel35;
    }

    public void setGroupPanel35(PanelGroup pg) {
        this.groupPanel35 = pg;
    }

    private StaticText staticText126 = new StaticText();

    public StaticText getStaticText126() {
        return staticText126;
    }

    public void setStaticText126(StaticText st) {
        this.staticText126 = st;
    }

    private Checkbox chkImgMa8 = new Checkbox();

    public Checkbox getChkImgMa8() {
        return chkImgMa8;
    }

    public void setChkImgMa8(Checkbox c) {
        this.chkImgMa8 = c;
    }

    private PanelGroup groupPanel36 = new PanelGroup();

    public PanelGroup getGroupPanel36() {
        return groupPanel36;
    }

    public void setGroupPanel36(PanelGroup pg) {
        this.groupPanel36 = pg;
    }

    private StaticText staticText127 = new StaticText();

    public StaticText getStaticText127() {
        return staticText127;
    }

    public void setStaticText127(StaticText st) {
        this.staticText127 = st;
    }

    private Checkbox chkImgMa10 = new Checkbox();

    public Checkbox getChkImgMa10() {
        return chkImgMa10;
    }

    public void setChkImgMa10(Checkbox c) {
        this.chkImgMa10 = c;
    }

    private HtmlPanelGrid gridPanel81 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel81() {
        return gridPanel81;
    }

    public void setGridPanel81(HtmlPanelGrid hpg) {
        this.gridPanel81 = hpg;
    }

    private StaticText staticText128 = new StaticText();

    public StaticText getStaticText128() {
        return staticText128;
    }

    public void setStaticText128(StaticText st) {
        this.staticText128 = st;
    }

    private PanelGroup groupPanel37 = new PanelGroup();

    public PanelGroup getGroupPanel37() {
        return groupPanel37;
    }

    public void setGroupPanel37(PanelGroup pg) {
        this.groupPanel37 = pg;
    }

    private Checkbox chkRestricaoCargas = new Checkbox();

    public Checkbox getChkRestricaoCargas() {
        return chkRestricaoCargas;
    }

    public void setChkRestricaoCargas(Checkbox c) {
        this.chkRestricaoCargas = c;
    }

    private StaticText staticText129 = new StaticText();

    public StaticText getStaticText129() {
        return staticText129;
    }

    public void setStaticText129(StaticText st) {
        this.staticText129 = st;
    }

    private RadioButton rbKgs2 = new RadioButton();

    public RadioButton getRbKgs2() {
        return rbKgs2;
    }

    public void setRbKgs2(RadioButton rb) {
        this.rbKgs2 = rb;
    }

    private StaticText stKgs2 = new StaticText();

    public StaticText getStKgs2() {
        return stKgs2;
    }

    public void setStKgs2(StaticText st) {
        this.stKgs2 = st;
    }

    private RadioButton rbKgs5 = new RadioButton();

    public RadioButton getRbKgs5() {
        return rbKgs5;
    }

    public void setRbKgs5(RadioButton rb) {
        this.rbKgs5 = rb;
    }

    private StaticText stKgs5 = new StaticText();

    public StaticText getStKgs5() {
        return stKgs5;
    }

    public void setStKgs5(StaticText st) {
        this.stKgs5 = st;
    }

    private RadioButton rbKgs10 = new RadioButton();

    public RadioButton getRbKgs10() {
        return rbKgs10;
    }

    public void setRbKgs10(RadioButton rb) {
        this.rbKgs10 = rb;
    }

    private StaticText stKgs10 = new StaticText();

    public StaticText getStKgs10() {
        return stKgs10;
    }

    public void setStKgs10(StaticText st) {
        this.stKgs10 = st;
    }

    private RadioButton rbKgs15 = new RadioButton();

    public RadioButton getRbKgs15() {
        return rbKgs15;
    }

    public void setRbKgs15(RadioButton rb) {
        this.rbKgs15 = rb;
    }

    private StaticText stKgs15 = new StaticText();

    public StaticText getStKgs15() {
        return stKgs15;
    }

    public void setStKgs15(StaticText st) {
        this.stKgs15 = st;
    }

    private RadioButton rbKgsOutro = new RadioButton();

    public RadioButton getRbKgsOutro() {
        return rbKgsOutro;
    }

    public void setRbKgsOutro(RadioButton rb) {
        this.rbKgsOutro = rb;
    }

    private StaticText stKgsOutro = new StaticText();

    public StaticText getStKgsOutro() {
        return stKgsOutro;
    }

    public void setStKgsOutro(StaticText st) {
        this.stKgsOutro = st;
    }

    private TextField txtKgs = new TextField();

    public TextField getTxtKgs() {
        return txtKgs;
    }

    public void setTxtKgs(TextField tf) {
        this.txtKgs = tf;
    }

    private StaticText stKg = new StaticText();

    public StaticText getStKg() {
        return stKg;
    }

    public void setStKg(StaticText st) {
        this.stKg = st;
    }

    private PanelGroup groupPanel38 = new PanelGroup();

    public PanelGroup getGroupPanel38() {
        return groupPanel38;
    }

    public void setGroupPanel38(PanelGroup pg) {
        this.groupPanel38 = pg;
    }

    private Checkbox chkRestricaoMotricidade = new Checkbox();

    public Checkbox getChkRestricaoMotricidade() {
        return chkRestricaoMotricidade;
    }

    public void setChkRestricaoMotricidade(Checkbox c) {
        this.chkRestricaoMotricidade = c;
    }

    private StaticText staticText136 = new StaticText();

    public StaticText getStaticText136() {
        return staticText136;
    }

    public void setStaticText136(StaticText st) {
        this.staticText136 = st;
    }

    private PanelGroup groupPanel39 = new PanelGroup();

    public PanelGroup getGroupPanel39() {
        return groupPanel39;
    }

    public void setGroupPanel39(PanelGroup pg) {
        this.groupPanel39 = pg;
    }

    private Checkbox chkRestricaoConducao = new Checkbox();

    public Checkbox getChkRestricaoConducao() {
        return chkRestricaoConducao;
    }

    public void setChkRestricaoConducao(Checkbox c) {
        this.chkRestricaoConducao = c;
    }

    private StaticText staticText137 = new StaticText();

    public StaticText getStaticText137() {
        return staticText137;
    }

    public void setStaticText137(StaticText st) {
        this.staticText137 = st;
    }

    private PanelGroup groupPanel40 = new PanelGroup();

    public PanelGroup getGroupPanel40() {
        return groupPanel40;
    }

    public void setGroupPanel40(PanelGroup pg) {
        this.groupPanel40 = pg;
    }

    private Checkbox chkRestricaoVibracoes = new Checkbox();

    public Checkbox getChkRestricaoVibracoes() {
        return chkRestricaoVibracoes;
    }

    public void setChkRestricaoVibracoes(Checkbox c) {
        this.chkRestricaoVibracoes = c;
    }

    private StaticText staticText138 = new StaticText();

    public StaticText getStaticText138() {
        return staticText138;
    }

    public void setStaticText138(StaticText st) {
        this.staticText138 = st;
    }

    private HtmlPanelGrid gridPanel82 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel82() {
        return gridPanel82;
    }

    public void setGridPanel82(HtmlPanelGrid hpg) {
        this.gridPanel82 = hpg;
    }

    private PanelGroup groupPanel41 = new PanelGroup();

    public PanelGroup getGroupPanel41() {
        return groupPanel41;
    }

    public void setGroupPanel41(PanelGroup pg) {
        this.groupPanel41 = pg;
    }

    private Checkbox chkRestricaoOutras = new Checkbox();

    public Checkbox getChkRestricaoOutras() {
        return chkRestricaoOutras;
    }

    public void setChkRestricaoOutras(Checkbox c) {
        this.chkRestricaoOutras = c;
    }

    private StaticText staticText139 = new StaticText();

    public StaticText getStaticText139() {
        return staticText139;
    }

    public void setStaticText139(StaticText st) {
        this.staticText139 = st;
    }

    private TextField txtRestricaoOutras = new TextField();

    public TextField getTxtRestricaoOutras() {
        return txtRestricaoOutras;
    }

    public void setTxtRestricaoOutras(TextField tf) {
        this.txtRestricaoOutras = tf;
    }

    private HtmlPanelGrid gridPanel83 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel83() {
        return gridPanel83;
    }

    public void setGridPanel83(HtmlPanelGrid hpg) {
        this.gridPanel83 = hpg;
    }

    private StaticText staticText140 = new StaticText();

    public StaticText getStaticText140() {
        return staticText140;
    }

    public void setStaticText140(StaticText st) {
        this.staticText140 = st;
    }

    private TextField txtObservacoes = new TextField();

    public TextField getTxtObservacoes() {
        return txtObservacoes;
    }

    public void setTxtObservacoes(TextField tf) {
        this.txtObservacoes = tf;
    }

    private RadioButton rbIncapacidadePerm = new RadioButton();

    public RadioButton getRbIncapacidadePerm() {
        return rbIncapacidadePerm;
    }

    public void setRbIncapacidadePerm(RadioButton rb) {
        this.rbIncapacidadePerm = rb;
    }

    private StaticText staticText141 = new StaticText();

    public StaticText getStaticText141() {
        return staticText141;
    }

    public void setStaticText141(StaticText st) {
        this.staticText141 = st;
    }

    private ImageComponent image17 = new ImageComponent();

    public ImageComponent getImage17() {
        return image17;
    }

    public void setImage17(ImageComponent ic) {
        this.image17 = ic;
    }

    private ImageComponent image18 = new ImageComponent();

    public ImageComponent getImage18() {
        return image18;
    }

    public void setImage18(ImageComponent ic) {
        this.image18 = ic;
    }

    private HtmlPanelGrid gridPanel84 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel84() {
        return gridPanel84;
    }

    public void setGridPanel84(HtmlPanelGrid hpg) {
        this.gridPanel84 = hpg;
    }

    private ImageComponent image19 = new ImageComponent();

    public ImageComponent getImage19() {
        return image19;
    }

    public void setImage19(ImageComponent ic) {
        this.image19 = ic;
    }

    private ImageComponent image20 = new ImageComponent();

    public ImageComponent getImage20() {
        return image20;
    }

    public void setImage20(ImageComponent ic) {
        this.image20 = ic;
    }

    private PanelGroup groupPanel42 = new PanelGroup();

    public PanelGroup getGroupPanel42() {
        return groupPanel42;
    }

    public void setGroupPanel42(PanelGroup pg) {
        this.groupPanel42 = pg;
    }

    private StaticText staticText142 = new StaticText();

    public StaticText getStaticText142() {
        return staticText142;
    }

    public void setStaticText142(StaticText st) {
        this.staticText142 = st;
    }

    private Checkbox chkImgRot1 = new Checkbox();

    public Checkbox getChkImgRot1() {
        return chkImgRot1;
    }

    public void setChkImgRot1(Checkbox c) {
        this.chkImgRot1 = c;
    }

    private PanelGroup groupPanel43 = new PanelGroup();

    public PanelGroup getGroupPanel43() {
        return groupPanel43;
    }

    public void setGroupPanel43(PanelGroup pg) {
        this.groupPanel43 = pg;
    }

    private StaticText staticText143 = new StaticText();

    public StaticText getStaticText143() {
        return staticText143;
    }

    public void setStaticText143(StaticText st) {
        this.staticText143 = st;
    }

    private Checkbox chkImgRot2 = new Checkbox();

    public Checkbox getChkImgRot2() {
        return chkImgRot2;
    }

    public void setChkImgRot2(Checkbox c) {
        this.chkImgRot2 = c;
    }

    private ImageComponent image21 = new ImageComponent();

    public ImageComponent getImage21() {
        return image21;
    }

    public void setImage21(ImageComponent ic) {
        this.image21 = ic;
    }

    private ImageComponent image11 = new ImageComponent();

    public ImageComponent getImage11() {
        return image11;
    }

    public void setImage11(ImageComponent ic) {
        this.image11 = ic;
    }

    private PanelGroup groupPanel44 = new PanelGroup();

    public PanelGroup getGroupPanel44() {
        return groupPanel44;
    }

    public void setGroupPanel44(PanelGroup pg) {
        this.groupPanel44 = pg;
    }

    private StaticText staticText144 = new StaticText();

    public StaticText getStaticText144() {
        return staticText144;
    }

    public void setStaticText144(StaticText st) {
        this.staticText144 = st;
    }

    private Checkbox chkImgCab1 = new Checkbox();

    public Checkbox getChkImgCab1() {
        return chkImgCab1;
    }

    public void setChkImgCab1(Checkbox c) {
        this.chkImgCab1 = c;
    }

    private PanelGroup groupPanel45 = new PanelGroup();

    public PanelGroup getGroupPanel45() {
        return groupPanel45;
    }

    public void setGroupPanel45(PanelGroup pg) {
        this.groupPanel45 = pg;
    }

    private StaticText staticText145 = new StaticText();

    public StaticText getStaticText145() {
        return staticText145;
    }

    public void setStaticText145(StaticText st) {
        this.staticText145 = st;
    }

    private Checkbox chkImgCab4 = new Checkbox();

    public Checkbox getChkImgCab4() {
        return chkImgCab4;
    }

    public void setChkImgCab4(Checkbox c) {
        this.chkImgCab4 = c;
    }

    private ImageComponent image22 = new ImageComponent();

    public ImageComponent getImage22() {
        return image22;
    }

    public void setImage22(ImageComponent ic) {
        this.image22 = ic;
    }

    private ImageComponent image23 = new ImageComponent();

    public ImageComponent getImage23() {
        return image23;
    }

    public void setImage23(ImageComponent ic) {
        this.image23 = ic;
    }

    private ImageComponent image24 = new ImageComponent();

    public ImageComponent getImage24() {
        return image24;
    }

    public void setImage24(ImageComponent ic) {
        this.image24 = ic;
    }

    private PanelGroup groupPanel46 = new PanelGroup();

    public PanelGroup getGroupPanel46() {
        return groupPanel46;
    }

    public void setGroupPanel46(PanelGroup pg) {
        this.groupPanel46 = pg;
    }

    private StaticText staticText146 = new StaticText();

    public StaticText getStaticText146() {
        return staticText146;
    }

    public void setStaticText146(StaticText st) {
        this.staticText146 = st;
    }

    private Checkbox chkImgMa1 = new Checkbox();

    public Checkbox getChkImgMa1() {
        return chkImgMa1;
    }

    public void setChkImgMa1(Checkbox c) {
        this.chkImgMa1 = c;
    }

    private PanelGroup groupPanel47 = new PanelGroup();

    public PanelGroup getGroupPanel47() {
        return groupPanel47;
    }

    public void setGroupPanel47(PanelGroup pg) {
        this.groupPanel47 = pg;
    }

    private StaticText staticText147 = new StaticText();

    public StaticText getStaticText147() {
        return staticText147;
    }

    public void setStaticText147(StaticText st) {
        this.staticText147 = st;
    }

    private Checkbox chkImgMa4 = new Checkbox();

    public Checkbox getChkImgMa4() {
        return chkImgMa4;
    }

    public void setChkImgMa4(Checkbox c) {
        this.chkImgMa4 = c;
    }

    private ImageComponent image25 = new ImageComponent();

    public ImageComponent getImage25() {
        return image25;
    }

    public void setImage25(ImageComponent ic) {
        this.image25 = ic;
    }

    private ImageComponent image26 = new ImageComponent();

    public ImageComponent getImage26() {
        return image26;
    }

    public void setImage26(ImageComponent ic) {
        this.image26 = ic;
    }

    private PanelGroup groupPanel48 = new PanelGroup();

    public PanelGroup getGroupPanel48() {
        return groupPanel48;
    }

    public void setGroupPanel48(PanelGroup pg) {
        this.groupPanel48 = pg;
    }

    private StaticText staticText148 = new StaticText();

    public StaticText getStaticText148() {
        return staticText148;
    }

    public void setStaticText148(StaticText st) {
        this.staticText148 = st;
    }

    private Checkbox chkImgMa7 = new Checkbox();

    public Checkbox getChkImgMa7() {
        return chkImgMa7;
    }

    public void setChkImgMa7(Checkbox c) {
        this.chkImgMa7 = c;
    }

    private PanelGroup groupPanel49 = new PanelGroup();

    public PanelGroup getGroupPanel49() {
        return groupPanel49;
    }

    public void setGroupPanel49(PanelGroup pg) {
        this.groupPanel49 = pg;
    }

    private StaticText staticText149 = new StaticText();

    public StaticText getStaticText149() {
        return staticText149;
    }

    public void setStaticText149(StaticText st) {
        this.staticText149 = st;
    }

    private Checkbox chkImgMa9 = new Checkbox();

    public Checkbox getChkImgMa9() {
        return chkImgMa9;
    }

    public void setChkImgMa9(Checkbox c) {
        this.chkImgMa9 = c;
    }

    private HtmlPanelGrid gridMedicoView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridMedicoView() {
        return gridMedicoView;
    }

    public void setGridMedicoView(HtmlPanelGrid hpg) {
        this.gridMedicoView = hpg;
    }

    private HtmlPanelGrid gridPanel85 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel85() {
        return gridPanel85;
    }

    public void setGridPanel85(HtmlPanelGrid hpg) {
        this.gridPanel85 = hpg;
    }

    private StaticText staticText150 = new StaticText();

    public StaticText getStaticText150() {
        return staticText150;
    }

    public void setStaticText150(StaticText st) {
        this.staticText150 = st;
    }

    private HtmlPanelGrid gridLesao = new HtmlPanelGrid();

    public HtmlPanelGrid getGridLesao() {
        return gridLesao;
    }

    public void setGridLesao(HtmlPanelGrid hpg) {
        this.gridLesao = hpg;
    }

    private StaticText staticText151 = new StaticText();

    public StaticText getStaticText151() {
        return staticText151;
    }

    public void setStaticText151(StaticText st) {
        this.staticText151 = st;
    }

    private HtmlPanelGrid gridPanel86 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel86() {
        return gridPanel86;
    }

    public void setGridPanel86(HtmlPanelGrid hpg) {
        this.gridPanel86 = hpg;
    }

    private StaticText staticText152 = new StaticText();

    public StaticText getStaticText152() {
        return staticText152;
    }

    public void setStaticText152(StaticText st) {
        this.staticText152 = st;
    }

    private HtmlPanelGrid gridIncapacidade2 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridIncapacidade2() {
        return gridIncapacidade2;
    }

    public void setGridIncapacidade2(HtmlPanelGrid hpg) {
        this.gridIncapacidade2 = hpg;
    }

    private HtmlPanelGrid gridPanel87 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel87() {
        return gridPanel87;
    }

    public void setGridPanel87(HtmlPanelGrid hpg) {
        this.gridPanel87 = hpg;
    }

    private StaticText staticText153 = new StaticText();

    public StaticText getStaticText153() {
        return staticText153;
    }

    public void setStaticText153(StaticText st) {
        this.staticText153 = st;
    }

    private HtmlPanelGrid gridRestricoes1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridRestricoes1() {
        return gridRestricoes1;
    }

    public void setGridRestricoes1(HtmlPanelGrid hpg) {
        this.gridRestricoes1 = hpg;
    }

    private HtmlPanelGrid gridPanel88 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel88() {
        return gridPanel88;
    }

    public void setGridPanel88(HtmlPanelGrid hpg) {
        this.gridPanel88 = hpg;
    }

    private HtmlPanelGrid gridImagesRestricoes = new HtmlPanelGrid();

    public HtmlPanelGrid getGridImagesRestricoes() {
        return gridImagesRestricoes;
    }

    public void setGridImagesRestricoes(HtmlPanelGrid hpg) {
        this.gridImagesRestricoes = hpg;
    }

    private HtmlPanelGrid gridOutrasRestricoes = new HtmlPanelGrid();

    public HtmlPanelGrid getGridOutrasRestricoes() {
        return gridOutrasRestricoes;
    }

    public void setGridOutrasRestricoes(HtmlPanelGrid hpg) {
        this.gridOutrasRestricoes = hpg;
    }

    private StaticText staticText154 = new StaticText();

    public StaticText getStaticText154() {
        return staticText154;
    }

    public void setStaticText154(StaticText st) {
        this.staticText154 = st;
    }

    private HtmlPanelGrid gridPanel90 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel90() {
        return gridPanel90;
    }

    public void setGridPanel90(HtmlPanelGrid hpg) {
        this.gridPanel90 = hpg;
    }

    private StaticText staticText155 = new StaticText();

    public StaticText getStaticText155() {
        return staticText155;
    }

    public void setStaticText155(StaticText st) {
        this.staticText155 = st;
    }

    private StaticText stObservacoes = new StaticText();

    public StaticText getStObservacoes() {
        return stObservacoes;
    }

    public void setStObservacoes(StaticText st) {
        this.stObservacoes = st;
    }

    private HtmlPanelGrid gridHeader1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridHeader1() {
        return gridHeader1;
    }

    public void setGridHeader1(HtmlPanelGrid hpg) {
        this.gridHeader1 = hpg;
    }

    private PanelGroup groupPanel56 = new PanelGroup();

    public PanelGroup getGroupPanel56() {
        return groupPanel56;
    }

    public void setGroupPanel56(PanelGroup pg) {
        this.groupPanel56 = pg;
    }

    private StaticText lblUser = new StaticText();

    public StaticText getLblUser() {
        return lblUser;
    }

    public void setLblUser(StaticText st) {
        this.lblUser = st;
    }

    private StaticText staticText165 = new StaticText();

    public StaticText getStaticText165() {
        return staticText165;
    }

    public void setStaticText165(StaticText st) {
        this.staticText165 = st;
    }

    private Hyperlink lnkEditUser = new Hyperlink();

    public Hyperlink getLnkEditUser() {
        return lnkEditUser;
    }

    public void setLnkEditUser(Hyperlink h) {
        this.lnkEditUser = h;
    }

    private StaticText staticText166 = new StaticText();

    public StaticText getStaticText166() {
        return staticText166;
    }

    public void setStaticText166(StaticText st) {
        this.staticText166 = st;
    }

    private Hyperlink lnkLogout = new Hyperlink();

    public Hyperlink getLnkLogout() {
        return lnkLogout;
    }

    public void setLnkLogout(Hyperlink h) {
        this.lnkLogout = h;
    }

    private HtmlPanelGrid gridPanel114 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel114() {
        return gridPanel114;
    }

    public void setGridPanel114(HtmlPanelGrid hpg) {
        this.gridPanel114 = hpg;
    }

    private PanelGroup groupPanel57 = new PanelGroup();

    public PanelGroup getGroupPanel57() {
        return groupPanel57;
    }

    public void setGroupPanel57(PanelGroup pg) {
        this.groupPanel57 = pg;
    }

    private ImageComponent image27 = new ImageComponent();

    public ImageComponent getImage27() {
        return image27;
    }

    public void setImage27(ImageComponent ic) {
        this.image27 = ic;
    }

    private HtmlPanelGrid gridPanel115 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel115() {
        return gridPanel115;
    }

    public void setGridPanel115(HtmlPanelGrid hpg) {
        this.gridPanel115 = hpg;
    }

    private StaticText staticText168 = new StaticText();

    public StaticText getStaticText168() {
        return staticText168;
    }

    public void setStaticText168(StaticText st) {
        this.staticText168 = st;
    }

    private HtmlPanelGrid gridPanel116 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel116() {
        return gridPanel116;
    }

    public void setGridPanel116(HtmlPanelGrid hpg) {
        this.gridPanel116 = hpg;
    }

    private PanelGroup groupPanel58 = new PanelGroup();

    public PanelGroup getGroupPanel58() {
        return groupPanel58;
    }

    public void setGroupPanel58(PanelGroup pg) {
        this.groupPanel58 = pg;
    }

    private StaticText staticText169 = new StaticText();

    public StaticText getStaticText169() {
        return staticText169;
    }

    public void setStaticText169(StaticText st) {
        this.staticText169 = st;
    }

    private StaticText stHeaderNr = new StaticText();

    public StaticText getStHeaderNr() {
        return stHeaderNr;
    }

    public void setStHeaderNr(StaticText st) {
        this.stHeaderNr = st;
    }

    private PanelGroup groupPanel59 = new PanelGroup();

    public PanelGroup getGroupPanel59() {
        return groupPanel59;
    }

    public void setGroupPanel59(PanelGroup pg) {
        this.groupPanel59 = pg;
    }

    private StaticText staticText170 = new StaticText();

    public StaticText getStaticText170() {
        return staticText170;
    }

    public void setStaticText170(StaticText st) {
        this.staticText170 = st;
    }

    private StaticText stHeaderDate = new StaticText();

    public StaticText getStHeaderDate() {
        return stHeaderDate;
    }

    public void setStHeaderDate(StaticText st) {
        this.stHeaderDate = st;
    }

    private ImageComponent image28 = new ImageComponent();

    public ImageComponent getImage28() {
        return image28;
    }

    public void setImage28(ImageComponent ic) {
        this.image28 = ic;
    }

    private PanelGroup groupPanel1 = new PanelGroup();

    public PanelGroup getGroupPanel1() {
        return groupPanel1;
    }

    public void setGroupPanel1(PanelGroup pg) {
        this.groupPanel1 = pg;
    }

    private RadioButton rbTurnoManha = new RadioButton();

    public RadioButton getRbTurnoManha() {
        return rbTurnoManha;
    }

    public void setRbTurnoManha(RadioButton rb) {
        this.rbTurnoManha = rb;
    }

    private StaticText staticText1 = new StaticText();

    public StaticText getStaticText1() {
        return staticText1;
    }

    public void setStaticText1(StaticText st) {
        this.staticText1 = st;
    }

    private StaticText staticText2 = new StaticText();

    public StaticText getStaticText2() {
        return staticText2;
    }

    public void setStaticText2(StaticText st) {
        this.staticText2 = st;
    }

    private RadioButton rbTurnoTarde = new RadioButton();

    public RadioButton getRbTurnoTarde() {
        return rbTurnoTarde;
    }

    public void setRbTurnoTarde(RadioButton rb) {
        this.rbTurnoTarde = rb;
    }

    private StaticText staticText3 = new StaticText();

    public StaticText getStaticText3() {
        return staticText3;
    }

    public void setStaticText3(StaticText st) {
        this.staticText3 = st;
    }

    private StaticText staticText41 = new StaticText();

    public StaticText getStaticText41() {
        return staticText41;
    }

    public void setStaticText41(StaticText st) {
        this.staticText41 = st;
    }

    private RadioButton rbTurnoNoite = new RadioButton();

    public RadioButton getRbTurnoNoite() {
        return rbTurnoNoite;
    }

    public void setRbTurnoNoite(RadioButton rb) {
        this.rbTurnoNoite = rb;
    }

    private StaticText staticText42 = new StaticText();

    public StaticText getStaticText42() {
        return staticText42;
    }

    public void setStaticText42(StaticText st) {
        this.staticText42 = st;
    }

    private HiddenField hidDisableEnviar = new HiddenField();

    public HiddenField getHidDisableEnviar() {
        return hidDisableEnviar;
    }

    public void setHidDisableEnviar(HiddenField hf) {
        this.hidDisableEnviar = hf;
    }

    private PanelGroup groupPanel2 = new PanelGroup();

    public PanelGroup getGroupPanel2() {
        return groupPanel2;
    }

    public void setGroupPanel2(PanelGroup pg) {
        this.groupPanel2 = pg;
    }

    private StaticText staticText43 = new StaticText();

    public StaticText getStaticText43() {
        return staticText43;
    }

    public void setStaticText43(StaticText st) {
        this.staticText43 = st;
    }

    private TextField txtNrMecanografico = new TextField();

    public TextField getTxtNrMecanografico() {
        return txtNrMecanografico;
    }

    public void setTxtNrMecanografico(TextField tf) {
        this.txtNrMecanografico = tf;
    }

    private StaticText staticText44 = new StaticText();

    public StaticText getStaticText44() {
        return staticText44;
    }

    public void setStaticText44(StaticText st) {
        this.staticText44 = st;
    }

    private TextField txtNomeTrabalhador = new TextField();

    public TextField getTxtNomeTrabalhador() {
        return txtNomeTrabalhador;
    }

    public void setTxtNomeTrabalhador(TextField tf) {
        this.txtNomeTrabalhador = tf;
    }

    private StaticText staticText45 = new StaticText();

    public StaticText getStaticText45() {
        return staticText45;
    }

    public void setStaticText45(StaticText st) {
        this.staticText45 = st;
    }

    private Button butProcurarTrab = new Button();

    public Button getButProcurarTrab() {
        return butProcurarTrab;
    }

    public void setButProcurarTrab(Button b) {
        this.butProcurarTrab = b;
    }

    private Table tblTrabalhadores = new Table();

    public Table getTblTrabalhadores() {
        return tblTrabalhadores;
    }

    public void setTblTrabalhadores(Table t) {
        this.tblTrabalhadores = t;
    }

    private TableRowGroup tableRowGroup1 = new TableRowGroup();

    public TableRowGroup getTableRowGroup1() {
        return tableRowGroup1;
    }

    public void setTableRowGroup1(TableRowGroup trg) {
        this.tableRowGroup1 = trg;
    }

    private TableColumn tableColumn1 = new TableColumn();

    public TableColumn getTableColumn1() {
        return tableColumn1;
    }

    public void setTableColumn1(TableColumn tc) {
        this.tableColumn1 = tc;
    }

    private TableColumn tableColumn2 = new TableColumn();

    public TableColumn getTableColumn2() {
        return tableColumn2;
    }

    public void setTableColumn2(TableColumn tc) {
        this.tableColumn2 = tc;
    }

    private TableColumn tableColumn3 = new TableColumn();

    public TableColumn getTableColumn3() {
        return tableColumn3;
    }

    public void setTableColumn3(TableColumn tc) {
        this.tableColumn3 = tc;
    }

    private DefaultTableDataProvider defaultTableDataProvider = new DefaultTableDataProvider();

    public DefaultTableDataProvider getDefaultTableDataProvider() {
        return defaultTableDataProvider;
    }

    public void setDefaultTableDataProvider(DefaultTableDataProvider dtdp) {
        this.defaultTableDataProvider = dtdp;
    }

    private Hyperlink lnkPOR = new Hyperlink();

    public Hyperlink getLnkPOR() {
        return lnkPOR;
    }

    public void setLnkPOR(Hyperlink h) {
        this.lnkPOR = h;
    }

    private Hyperlink lnkNomeTrabalhador = new Hyperlink();

    public Hyperlink getLnkNomeTrabalhador() {
        return lnkNomeTrabalhador;
    }

    public void setLnkNomeTrabalhador(Hyperlink h) {
        this.lnkNomeTrabalhador = h;
    }

    private Hyperlink lnkEstabelecimentoTrabalhador = new Hyperlink();

    public Hyperlink getLnkEstabelecimentoTrabalhador() {
        return lnkEstabelecimentoTrabalhador;
    }

    public void setLnkEstabelecimentoTrabalhador(Hyperlink h) {
        this.lnkEstabelecimentoTrabalhador = h;
    }

    private StaticText stTecnicoNomeEdit = new StaticText();

    public StaticText getStTecnicoNomeEdit() {
        return stTecnicoNomeEdit;
    }

    public void setStTecnicoNomeEdit(StaticText st) {
        this.stTecnicoNomeEdit = st;
    }

    private HtmlPanelGrid gridDadosAcidenteSegView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridDadosAcidenteSegView() {
        return gridDadosAcidenteSegView;
    }

    public void setGridDadosAcidenteSegView(HtmlPanelGrid hpg) {
        this.gridDadosAcidenteSegView = hpg;
    }

    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel1() {
        return gridPanel1;
    }

    public void setGridPanel1(HtmlPanelGrid hpg) {
        this.gridPanel1 = hpg;
    }

    private StaticText staticText95 = new StaticText();

    public StaticText getStaticText95() {
        return staticText95;
    }

    public void setStaticText95(StaticText st) {
        this.staticText95 = st;
    }

    private HtmlPanelGrid gridPanel117 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel117() {
        return gridPanel117;
    }

    public void setGridPanel117(HtmlPanelGrid hpg) {
        this.gridPanel117 = hpg;
    }

    private HtmlPanelGrid gridTurnoSeccaoLocal = new HtmlPanelGrid();

    public HtmlPanelGrid getGridTurnoSeccaoLocal() {
        return gridTurnoSeccaoLocal;
    }

    public void setGridTurnoSeccaoLocal(HtmlPanelGrid hpg) {
        this.gridTurnoSeccaoLocal = hpg;
    }

    private StaticText lblHorasTurno = new StaticText();

    public StaticText getLblHorasTurno() {
        return lblHorasTurno;
    }

    public void setLblHorasTurno(StaticText st) {
        this.lblHorasTurno = st;
    }

    private StaticText txtHorasTurno2 = new StaticText();

    public StaticText getTxtHorasTurno2() {
        return txtHorasTurno2;
    }

    public void setTxtHorasTurno2(StaticText st) {
        this.txtHorasTurno2 = st;
    }

    private StaticText lblSeccao = new StaticText();

    public StaticText getLblSeccao() {
        return lblSeccao;
    }

    public void setLblSeccao(StaticText st) {
        this.lblSeccao = st;
    }

    private StaticText txtSeccao1 = new StaticText();

    public StaticText getTxtSeccao1() {
        return txtSeccao1;
    }

    public void setTxtSeccao1(StaticText st) {
        this.txtSeccao1 = st;
    }

    private StaticText lblLocal = new StaticText();

    public StaticText getLblLocal() {
        return lblLocal;
    }

    public void setLblLocal(StaticText st) {
        this.lblLocal = st;
    }

    private StaticText txtLocal1 = new StaticText();

    public StaticText getTxtLocal1() {
        return txtLocal1;
    }

    public void setTxtLocal1(StaticText st) {
        this.txtLocal1 = st;
    }

    private HtmlPanelGrid gridTarefa = new HtmlPanelGrid();

    public HtmlPanelGrid getGridTarefa() {
        return gridTarefa;
    }

    public void setGridTarefa(HtmlPanelGrid hpg) {
        this.gridTarefa = hpg;
    }

    private StaticText lblTarefa = new StaticText();

    public StaticText getLblTarefa() {
        return lblTarefa;
    }

    public void setLblTarefa(StaticText st) {
        this.lblTarefa = st;
    }

    private StaticText txtTarefa1 = new StaticText();

    public StaticText getTxtTarefa1() {
        return txtTarefa1;
    }

    public void setTxtTarefa1(StaticText st) {
        this.txtTarefa1 = st;
    }

    private HtmlPanelGrid gridSubstancias = new HtmlPanelGrid();

    public HtmlPanelGrid getGridSubstancias() {
        return gridSubstancias;
    }

    public void setGridSubstancias(HtmlPanelGrid hpg) {
        this.gridSubstancias = hpg;
    }

    private StaticText lblSubstancias = new StaticText();

    public StaticText getLblSubstancias() {
        return lblSubstancias;
    }

    public void setLblSubstancias(StaticText st) {
        this.lblSubstancias = st;
    }

    private StaticText txtSubstancias1 = new StaticText();

    public StaticText getTxtSubstancias1() {
        return txtSubstancias1;
    }

    public void setTxtSubstancias1(StaticText st) {
        this.txtSubstancias1 = st;
    }

    private HtmlPanelGrid gridCondicoes = new HtmlPanelGrid();

    public HtmlPanelGrid getGridCondicoes() {
        return gridCondicoes;
    }

    public void setGridCondicoes(HtmlPanelGrid hpg) {
        this.gridCondicoes = hpg;
    }

    private StaticText lblCondicoes = new StaticText();

    public StaticText getLblCondicoes() {
        return lblCondicoes;
    }

    public void setLblCondicoes(StaticText st) {
        this.lblCondicoes = st;
    }

    private StaticText txtCondicoes1 = new StaticText();

    public StaticText getTxtCondicoes1() {
        return txtCondicoes1;
    }

    public void setTxtCondicoes1(StaticText st) {
        this.txtCondicoes1 = st;
    }

    private HtmlPanelGrid gridTestemunhas = new HtmlPanelGrid();

    public HtmlPanelGrid getGridTestemunhas() {
        return gridTestemunhas;
    }

    public void setGridTestemunhas(HtmlPanelGrid hpg) {
        this.gridTestemunhas = hpg;
    }

    private StaticText lblTestemunhas = new StaticText();

    public StaticText getLblTestemunhas() {
        return lblTestemunhas;
    }

    public void setLblTestemunhas(StaticText st) {
        this.lblTestemunhas = st;
    }

    private StaticText txtTestemunhas1 = new StaticText();

    public StaticText getTxtTestemunhas1() {
        return txtTestemunhas1;
    }

    public void setTxtTestemunhas1(StaticText st) {
        this.txtTestemunhas1 = st;
    }

    private HtmlPanelGrid gridCausas = new HtmlPanelGrid();

    public HtmlPanelGrid getGridCausas() {
        return gridCausas;
    }

    public void setGridCausas(HtmlPanelGrid hpg) {
        this.gridCausas = hpg;
    }

    private StaticText lblCausas = new StaticText();

    public StaticText getLblCausas() {
        return lblCausas;
    }

    public void setLblCausas(StaticText st) {
        this.lblCausas = st;
    }

    private StaticText txtCausas1 = new StaticText();

    public StaticText getTxtCausas1() {
        return txtCausas1;
    }

    public void setTxtCausas1(StaticText st) {
        this.txtCausas1 = st;
    }

    private HtmlPanelGrid gridDescricao = new HtmlPanelGrid();

    public HtmlPanelGrid getGridDescricao() {
        return gridDescricao;
    }

    public void setGridDescricao(HtmlPanelGrid hpg) {
        this.gridDescricao = hpg;
    }

    private StaticText lblDescricao = new StaticText();

    public StaticText getLblDescricao() {
        return lblDescricao;
    }

    public void setLblDescricao(StaticText st) {
        this.lblDescricao = st;
    }

    private StaticText txtDescricao1 = new StaticText();

    public StaticText getTxtDescricao1() {
        return txtDescricao1;
    }

    public void setTxtDescricao1(StaticText st) {
        this.txtDescricao1 = st;
    }

    private HtmlPanelGrid gridFotografias = new HtmlPanelGrid();

    public HtmlPanelGrid getGridFotografias() {
        return gridFotografias;
    }

    public void setGridFotografias(HtmlPanelGrid hpg) {
        this.gridFotografias = hpg;
    }

    private HtmlPanelGrid gridPanel127 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel127() {
        return gridPanel127;
    }

    public void setGridPanel127(HtmlPanelGrid hpg) {
        this.gridPanel127 = hpg;
    }

    private StaticText lblFotografias = new StaticText();

    public StaticText getLblFotografias() {
        return lblFotografias;
    }

    public void setLblFotografias(StaticText st) {
        this.lblFotografias = st;
    }

    private HtmlPanelGrid gridImages1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridImages1() {
        return gridImages1;
    }

    public void setGridImages1(HtmlPanelGrid hpg) {
        this.gridImages1 = hpg;
    }

    private HtmlPanelGrid gridConclusoes = new HtmlPanelGrid();

    public HtmlPanelGrid getGridConclusoes() {
        return gridConclusoes;
    }

    public void setGridConclusoes(HtmlPanelGrid hpg) {
        this.gridConclusoes = hpg;
    }

    private StaticText lblConclusoes = new StaticText();

    public StaticText getLblConclusoes() {
        return lblConclusoes;
    }

    public void setLblConclusoes(StaticText st) {
        this.lblConclusoes = st;
    }

    private StaticText txtConclusoes1 = new StaticText();

    public StaticText getTxtConclusoes1() {
        return txtConclusoes1;
    }

    public void setTxtConclusoes1(StaticText st) {
        this.txtConclusoes1 = st;
    }

    private HtmlPanelGrid gridAccoes = new HtmlPanelGrid();

    public HtmlPanelGrid getGridAccoes() {
        return gridAccoes;
    }

    public void setGridAccoes(HtmlPanelGrid hpg) {
        this.gridAccoes = hpg;
    }

    private StaticText lblAccoes = new StaticText();

    public StaticText getLblAccoes() {
        return lblAccoes;
    }

    public void setLblAccoes(StaticText st) {
        this.lblAccoes = st;
    }

    private StaticText txtAccoes1 = new StaticText();

    public StaticText getTxtAccoes1() {
        return txtAccoes1;
    }

    public void setTxtAccoes1(StaticText st) {
        this.txtAccoes1 = st;
    }

    private HtmlPanelGrid gridDataHora = new HtmlPanelGrid();

    public HtmlPanelGrid getGridDataHora() {
        return gridDataHora;
    }

    public void setGridDataHora(HtmlPanelGrid hpg) {
        this.gridDataHora = hpg;
    }

    private PanelGroup groupPanel7 = new PanelGroup();

    public PanelGroup getGroupPanel7() {
        return groupPanel7;
    }

    public void setGroupPanel7(PanelGroup pg) {
        this.groupPanel7 = pg;
    }

    private StaticText lblDataAcidente = new StaticText();

    public StaticText getLblDataAcidente() {
        return lblDataAcidente;
    }

    public void setLblDataAcidente(StaticText st) {
        this.lblDataAcidente = st;
    }

    private StaticText stDataAcidente1 = new StaticText();

    public StaticText getStDataAcidente1() {
        return stDataAcidente1;
    }

    public void setStDataAcidente1(StaticText st) {
        this.stDataAcidente1 = st;
    }

    private PanelGroup groupPanel60 = new PanelGroup();

    public PanelGroup getGroupPanel60() {
        return groupPanel60;
    }

    public void setGroupPanel60(PanelGroup pg) {
        this.groupPanel60 = pg;
    }

    private StaticText lblHoraAcidente = new StaticText();

    public StaticText getLblHoraAcidente() {
        return lblHoraAcidente;
    }

    public void setLblHoraAcidente(StaticText st) {
        this.lblHoraAcidente = st;
    }

    private StaticText stHoraAcidente1 = new StaticText();

    public StaticText getStHoraAcidente1() {
        return stHoraAcidente1;
    }

    public void setStHoraAcidente1(StaticText st) {
        this.stHoraAcidente1 = st;
    }

    private HtmlPanelGrid gridVerificacao = new HtmlPanelGrid();

    public HtmlPanelGrid getGridVerificacao() {
        return gridVerificacao;
    }

    public void setGridVerificacao(HtmlPanelGrid hpg) {
        this.gridVerificacao = hpg;
    }

    private HtmlPanelGrid gridPanel131 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel131() {
        return gridPanel131;
    }

    public void setGridPanel131(HtmlPanelGrid hpg) {
        this.gridPanel131 = hpg;
    }

    private StaticText staticText52 = new StaticText();

    public StaticText getStaticText52() {
        return staticText52;
    }

    public void setStaticText52(StaticText st) {
        this.staticText52 = st;
    }

    private HtmlPanelGrid gridPanel132 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel132() {
        return gridPanel132;
    }

    public void setGridPanel132(HtmlPanelGrid hpg) {
        this.gridPanel132 = hpg;
    }

    private HtmlPanelGrid gridPanel133 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel133() {
        return gridPanel133;
    }

    public void setGridPanel133(HtmlPanelGrid hpg) {
        this.gridPanel133 = hpg;
    }

    private PanelGroup grpVerHs = new PanelGroup();

    public PanelGroup getGrpVerHs() {
        return grpVerHs;
    }

    public void setGrpVerHs(PanelGroup pg) {
        this.grpVerHs = pg;
    }

    private Checkbox chkVerHs = new Checkbox();

    public Checkbox getChkVerHs() {
        return chkVerHs;
    }

    public void setChkVerHs(Checkbox c) {
        this.chkVerHs = c;
    }

    private StaticText stVerHs = new StaticText();

    public StaticText getStVerHs() {
        return stVerHs;
    }

    public void setStVerHs(StaticText st) {
        this.stVerHs = st;
    }

    private PanelGroup grpVerRespSeg = new PanelGroup();

    public PanelGroup getGrpVerRespSeg() {
        return grpVerRespSeg;
    }

    public void setGrpVerRespSeg(PanelGroup pg) {
        this.grpVerRespSeg = pg;
    }

    private Checkbox chkVerRespSeg = new Checkbox();

    public Checkbox getChkVerRespSeg() {
        return chkVerRespSeg;
    }

    public void setChkVerRespSeg(Checkbox c) {
        this.chkVerRespSeg = c;
    }

    private StaticText stVerRespSeg = new StaticText();

    public StaticText getStVerRespSeg() {
        return stVerRespSeg;
    }

    public void setStVerRespSeg(StaticText st) {
        this.stVerRespSeg = st;
    }

    private PanelGroup grpVerRespRh = new PanelGroup();

    public PanelGroup getGrpVerRespRh() {
        return grpVerRespRh;
    }

    public void setGrpVerRespRh(PanelGroup pg) {
        this.grpVerRespRh = pg;
    }

    private Checkbox chkVerRespRh = new Checkbox();

    public Checkbox getChkVerRespRh() {
        return chkVerRespRh;
    }

    public void setChkVerRespRh(Checkbox c) {
        this.chkVerRespRh = c;
    }

    private StaticText stVerRespRh = new StaticText();

    public StaticText getStVerRespRh() {
        return stVerRespRh;
    }

    public void setStVerRespRh(StaticText st) {
        this.stVerRespRh = st;
    }

    private HtmlPanelGrid gridVerificacaoView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridVerificacaoView() {
        return gridVerificacaoView;
    }

    public void setGridVerificacaoView(HtmlPanelGrid hpg) {
        this.gridVerificacaoView = hpg;
    }

    private HtmlPanelGrid gridPanel134 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel134() {
        return gridPanel134;
    }

    public void setGridPanel134(HtmlPanelGrid hpg) {
        this.gridPanel134 = hpg;
    }

    private StaticText staticText187 = new StaticText();

    public StaticText getStaticText187() {
        return staticText187;
    }

    public void setStaticText187(StaticText st) {
        this.staticText187 = st;
    }

    private HtmlPanelGrid gridPanel135 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel135() {
        return gridPanel135;
    }

    public void setGridPanel135(HtmlPanelGrid hpg) {
        this.gridPanel135 = hpg;
    }

    private HtmlPanelGrid gridAssinaturasView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridAssinaturasView() {
        return gridAssinaturasView;
    }

    public void setGridAssinaturasView(HtmlPanelGrid hpg) {
        this.gridAssinaturasView = hpg;
    }

    private DropDown drpCausas = new DropDown();

    public DropDown getDrpCausas() {
        return drpCausas;
    }

    public void setDrpCausas(DropDown dd) {
        this.drpCausas = dd;
    }

    private StaticText stObservacoesCorr = new StaticText();

    public StaticText getStObservacoesCorr() {
        return stObservacoesCorr;
    }

    public void setStObservacoesCorr(StaticText st) {
        this.stObservacoesCorr = st;
    }

    private HtmlPanelGrid gridImpressao = new HtmlPanelGrid();

    public HtmlPanelGrid getGridImpressao() {
        return gridImpressao;
    }

    public void setGridImpressao(HtmlPanelGrid hpg) {
        this.gridImpressao = hpg;
    }

    private HtmlPanelGrid gridPanel89 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel89() {
        return gridPanel89;
    }

    public void setGridPanel89(HtmlPanelGrid hpg) {
        this.gridPanel89 = hpg;
    }

    private StaticText staticText73 = new StaticText();

    public StaticText getStaticText73() {
        return staticText73;
    }

    public void setStaticText73(StaticText st) {
        this.staticText73 = st;
    }

    private HtmlPanelGrid gridPanel91 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel91() {
        return gridPanel91;
    }

    public void setGridPanel91(HtmlPanelGrid hpg) {
        this.gridPanel91 = hpg;
    }

    private HtmlPanelGrid gridPanel92 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel92() {
        return gridPanel92;
    }

    public void setGridPanel92(HtmlPanelGrid hpg) {
        this.gridPanel92 = hpg;
    }

    private PanelGroup grpAssSup = new PanelGroup();

    public PanelGroup getGrpAssSup() {
        return grpAssSup;
    }

    public void setGrpAssSup(PanelGroup pg) {
        this.grpAssSup = pg;
    }

    private Checkbox chkAssSup = new Checkbox();

    public Checkbox getChkAssSup() {
        return chkAssSup;
    }

    public void setChkAssSup(Checkbox c) {
        this.chkAssSup = c;
    }

    private StaticText stAssSup1 = new StaticText();

    public StaticText getStAssSup1() {
        return stAssSup1;
    }

    public void setStAssSup1(StaticText st) {
        this.stAssSup1 = st;
    }

    private HtmlPanelGrid gridImpressaoView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridImpressaoView() {
        return gridImpressaoView;
    }

    public void setGridImpressaoView(HtmlPanelGrid hpg) {
        this.gridImpressaoView = hpg;
    }

    private HtmlPanelGrid gridPanel93 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel93() {
        return gridPanel93;
    }

    public void setGridPanel93(HtmlPanelGrid hpg) {
        this.gridPanel93 = hpg;
    }

    private StaticText staticText76 = new StaticText();

    public StaticText getStaticText76() {
        return staticText76;
    }

    public void setStaticText76(StaticText st) {
        this.staticText76 = st;
    }

    private HtmlPanelGrid gridPanel94 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel94() {
        return gridPanel94;
    }

    public void setGridPanel94(HtmlPanelGrid hpg) {
        this.gridPanel94 = hpg;
    }

    private HtmlPanelGrid gridAssSupView = new HtmlPanelGrid();

    public HtmlPanelGrid getGridAssSupView() {
        return gridAssSupView;
    }

    public void setGridAssSupView(HtmlPanelGrid hpg) {
        this.gridAssSupView = hpg;
    }

    private HtmlPanelGrid gridPanel22 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel22() {
        return gridPanel22;
    }

    public void setGridPanel22(HtmlPanelGrid hpg) {
        this.gridPanel22 = hpg;
    }

    private Button butCancelar = new Button();

    public Button getButCancelar() {
        return butCancelar;
    }

    public void setButCancelar(Button b) {
        this.butCancelar = b;
    }

    private PanelGroup groupPanel5 = new PanelGroup();

    public PanelGroup getGroupPanel5() {
        return groupPanel5;
    }

    public void setGroupPanel5(PanelGroup pg) {
        this.groupPanel5 = pg;
    }

    private Button butImprimir = new Button();

    public Button getButImprimir() {
        return butImprimir;
    }

    public void setButImprimir(Button b) {
        this.butImprimir = b;
    }

    private Button butGravar = new Button();

    public Button getButGravar() {
        return butGravar;
    }

    public void setButGravar(Button b) {
        this.butGravar = b;
    }

    private Button butCorrecao = new Button();

    public Button getButCorrecao() {
        return butCorrecao;
    }

    public void setButCorrecao(Button b) {
        this.butCorrecao = b;
    }

    private Button butEnviar = new Button();

    public Button getButEnviar() {
        return butEnviar;
    }

    public void setButEnviar(Button b) {
        this.butEnviar = b;
    }

    private TextField txtAssSup = new TextField();

    public TextField getTxtAssSup() {
        return txtAssSup;
    }

    public void setTxtAssSup(TextField tf) {
        this.txtAssSup = tf;
    }

    private StaticText stAssSup2 = new StaticText();

    public StaticText getStAssSup2() {
        return stAssSup2;
    }

    public void setStAssSup2(StaticText st) {
        this.stAssSup2 = st;
    }

    private HtmlPanelGrid gridPanel95 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel95() {
        return gridPanel95;
    }

    public void setGridPanel95(HtmlPanelGrid hpg) {
        this.gridPanel95 = hpg;
    }

    private PanelGroup groupPanel50 = new PanelGroup();

    public PanelGroup getGroupPanel50() {
        return groupPanel50;
    }

    public void setGroupPanel50(PanelGroup pg) {
        this.groupPanel50 = pg;
    }

    private StaticText staticText98 = new StaticText();

    public StaticText getStaticText98() {
        return staticText98;
    }

    public void setStaticText98(StaticText st) {
        this.staticText98 = st;
    }

    private TextField txtAveriguador = new TextField();

    public TextField getTxtAveriguador() {
        return txtAveriguador;
    }

    public void setTxtAveriguador(TextField tf) {
        this.txtAveriguador = tf;
    }

    private HtmlPanelGrid gridPanel96 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel96() {
        return gridPanel96;
    }

    public void setGridPanel96(HtmlPanelGrid hpg) {
        this.gridPanel96 = hpg;
    }

    private PanelGroup groupPanel51 = new PanelGroup();

    public PanelGroup getGroupPanel51() {
        return groupPanel51;
    }

    public void setGroupPanel51(PanelGroup pg) {
        this.groupPanel51 = pg;
    }

    private StaticText staticText101 = new StaticText();

    public StaticText getStaticText101() {
        return staticText101;
    }

    public void setStaticText101(StaticText st) {
        this.staticText101 = st;
    }

    private StaticText stAveriguador = new StaticText();

    public StaticText getStAveriguador() {
        return stAveriguador;
    }

    public void setStAveriguador(StaticText st) {
        this.stAveriguador = st;
    }

    private HtmlPanelGrid gridPanel97 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel97() {
        return gridPanel97;
    }

    public void setGridPanel97(HtmlPanelGrid hpg) {
        this.gridPanel97 = hpg;
    }

    private PanelGroup groupPanel52 = new PanelGroup();

    public PanelGroup getGroupPanel52() {
        return groupPanel52;
    }

    public void setGroupPanel52(PanelGroup pg) {
        this.groupPanel52 = pg;
    }

    private Checkbox chkAveriguacaoPosterior = new Checkbox();

    public Checkbox getChkAveriguacaoPosterior() {
        return chkAveriguacaoPosterior;
    }

    public void setChkAveriguacaoPosterior(Checkbox c) {
        this.chkAveriguacaoPosterior = c;
    }

    private StaticText staticText132 = new StaticText();

    public StaticText getStaticText132() {
        return staticText132;
    }

    public void setStaticText132(StaticText st) {
        this.staticText132 = st;
    }

    private HtmlPanelGrid gridPanel98 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel98() {
        return gridPanel98;
    }

    public void setGridPanel98(HtmlPanelGrid hpg) {
        this.gridPanel98 = hpg;
    }

    private StaticText staticText104 = new StaticText();

    public StaticText getStaticText104() {
        return staticText104;
    }

    public void setStaticText104(StaticText st) {
        this.staticText104 = st;
    }

    private HtmlPanelGrid gridPanel99 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel99() {
        return gridPanel99;
    }

    public void setGridPanel99(HtmlPanelGrid hpg) {
        this.gridPanel99 = hpg;
    }

    private StaticText staticText131 = new StaticText();

    public StaticText getStaticText131() {
        return staticText131;
    }

    public void setStaticText131(StaticText st) {
        this.staticText131 = st;
    }

    private TextArea txtAveriguacaoObs = new TextArea();

    public TextArea getTxtAveriguacaoObs() {
        return txtAveriguacaoObs;
    }

    public void setTxtAveriguacaoObs(TextArea ta) {
        this.txtAveriguacaoObs = ta;
    }

    private HtmlPanelGrid gridAveriguacaoPosterior = new HtmlPanelGrid();

    public HtmlPanelGrid getGridAveriguacaoPosterior() {
        return gridAveriguacaoPosterior;
    }

    public void setGridAveriguacaoPosterior(HtmlPanelGrid hpg) {
        this.gridAveriguacaoPosterior = hpg;
    }

    private StaticText lblAveriguacaoPosterior = new StaticText();

    public StaticText getLblAveriguacaoPosterior() {
        return lblAveriguacaoPosterior;
    }

    public void setLblAveriguacaoPosterior(StaticText st) {
        this.lblAveriguacaoPosterior = st;
    }

    private StaticText txtAveriguacaoPosterior = new StaticText();

    public StaticText getTxtAveriguacaoPosterior() {
        return txtAveriguacaoPosterior;
    }

    public void setTxtAveriguacaoPosterior(StaticText st) {
        this.txtAveriguacaoPosterior = st;
    }

    private HtmlPanelGrid gridAveriguacaoPosterior1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridAveriguacaoPosterior1() {
        return gridAveriguacaoPosterior1;
    }

    public void setGridAveriguacaoPosterior1(HtmlPanelGrid hpg) {
        this.gridAveriguacaoPosterior1 = hpg;
    }

    private HtmlPanelGrid gridPanel101 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel101() {
        return gridPanel101;
    }

    public void setGridPanel101(HtmlPanelGrid hpg) {
        this.gridPanel101 = hpg;
    }

    private StaticText staticText134 = new StaticText();

    public StaticText getStaticText134() {
        return staticText134;
    }

    public void setStaticText134(StaticText st) {
        this.staticText134 = st;
    }

    private HtmlPanelGrid gridPanel102 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel102() {
        return gridPanel102;
    }

    public void setGridPanel102(HtmlPanelGrid hpg) {
        this.gridPanel102 = hpg;
    }

    private StaticText staticText135 = new StaticText();

    public StaticText getStaticText135() {
        return staticText135;
    }

    public void setStaticText135(StaticText st) {
        this.staticText135 = st;
    }

    private TextArea txtAveriguacaoObs1 = new TextArea();

    public TextArea getTxtAveriguacaoObs1() {
        return txtAveriguacaoObs1;
    }

    public void setTxtAveriguacaoObs1(TextArea ta) {
        this.txtAveriguacaoObs1 = ta;
    }

    private StaticText staticText130 = new StaticText();

    public StaticText getStaticText130() {
        return staticText130;
    }

    public void setStaticText130(StaticText st) {
        this.staticText130 = st;
    }

    private StaticText stEstabelecimentoOrigem = new StaticText();

    public StaticText getStEstabelecimentoOrigem() {
        return stEstabelecimentoOrigem;
    }

    public void setStEstabelecimentoOrigem(StaticText st) {
        this.stEstabelecimentoOrigem = st;
    }

    private HtmlPanelGrid gridPanel100 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel100() {
        return gridPanel100;
    }

    public void setGridPanel100(HtmlPanelGrid hpg) {
        this.gridPanel100 = hpg;
    }

    private StaticText staticText156 = new StaticText();

    public StaticText getStaticText156() {
        return staticText156;
    }

    public void setStaticText156(StaticText st) {
        this.staticText156 = st;
    }

    private HtmlPanelGrid gridPanel103 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel103() {
        return gridPanel103;
    }

    public void setGridPanel103(HtmlPanelGrid hpg) {
        this.gridPanel103 = hpg;
    }

    private PanelGroup groupPanel53 = new PanelGroup();

    public PanelGroup getGroupPanel53() {
        return groupPanel53;
    }

    public void setGroupPanel53(PanelGroup pg) {
        this.groupPanel53 = pg;
    }

    private StaticText staticText157 = new StaticText();

    public StaticText getStaticText157() {
        return staticText157;
    }

    public void setStaticText157(StaticText st) {
        this.staticText157 = st;
    }

    private TextField txtNomeSuperior = new TextField();

    public TextField getTxtNomeSuperior() {
        return txtNomeSuperior;
    }

    public void setTxtNomeSuperior(TextField tf) {
        this.txtNomeSuperior = tf;
    }

    private PanelGroup groupPanel54 = new PanelGroup();

    public PanelGroup getGroupPanel54() {
        return groupPanel54;
    }

    public void setGroupPanel54(PanelGroup pg) {
        this.groupPanel54 = pg;
    }

    private StaticText staticText158 = new StaticText();

    public StaticText getStaticText158() {
        return staticText158;
    }

    public void setStaticText158(StaticText st) {
        this.staticText158 = st;
    }

    private TextField txtEmailSuperior = new TextField();

    public TextField getTxtEmailSuperior() {
        return txtEmailSuperior;
    }

    public void setTxtEmailSuperior(TextField tf) {
        this.txtEmailSuperior = tf;
    }

    private HtmlPanelGrid gridPanel104 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel104() {
        return gridPanel104;
    }

    public void setGridPanel104(HtmlPanelGrid hpg) {
        this.gridPanel104 = hpg;
    }

    private StaticText staticText159 = new StaticText();

    public StaticText getStaticText159() {
        return staticText159;
    }

    public void setStaticText159(StaticText st) {
        this.staticText159 = st;
    }

    private HtmlPanelGrid gridPanel105 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel105() {
        return gridPanel105;
    }

    public void setGridPanel105(HtmlPanelGrid hpg) {
        this.gridPanel105 = hpg;
    }

    private PanelGroup groupPanel55 = new PanelGroup();

    public PanelGroup getGroupPanel55() {
        return groupPanel55;
    }

    public void setGroupPanel55(PanelGroup pg) {
        this.groupPanel55 = pg;
    }

    private StaticText staticText160 = new StaticText();

    public StaticText getStaticText160() {
        return staticText160;
    }

    public void setStaticText160(StaticText st) {
        this.staticText160 = st;
    }

    private StaticText stNomeSuperior = new StaticText();

    public StaticText getStNomeSuperior() {
        return stNomeSuperior;
    }

    public void setStNomeSuperior(StaticText st) {
        this.stNomeSuperior = st;
    }

    private PanelGroup groupPanel61 = new PanelGroup();

    public PanelGroup getGroupPanel61() {
        return groupPanel61;
    }

    public void setGroupPanel61(PanelGroup pg) {
        this.groupPanel61 = pg;
    }

    private StaticText staticText162 = new StaticText();

    public StaticText getStaticText162() {
        return staticText162;
    }

    public void setStaticText162(StaticText st) {
        this.staticText162 = st;
    }

    private StaticText stEmailSuperior = new StaticText();

    public StaticText getStEmailSuperior() {
        return stEmailSuperior;
    }

    public void setStEmailSuperior(StaticText st) {
        this.stEmailSuperior = st;
    }

    private Hyperlink lnkNewUser1 = new Hyperlink();

    public Hyperlink getLnkNewUser1() {
        return lnkNewUser1;
    }

    public void setLnkNewUser1(Hyperlink h) {
        this.lnkNewUser1 = h;
    }

    private StaticText staticText21 = new StaticText();

    public StaticText getStaticText21() {
        return staticText21;
    }

    public void setStaticText21(StaticText st) {
        this.staticText21 = st;
    }

    private StaticText staticText161 = new StaticText();

    public StaticText getStaticText161() {
        return staticText161;
    }

    public void setStaticText161(StaticText st) {
        this.staticText161 = st;
    }

    private Hyperlink lnkAnalisesAcidente = new Hyperlink();

    public Hyperlink getLnkAnalisesAcidente() {
        return lnkAnalisesAcidente;
    }

    public void setLnkAnalisesAcidente(Hyperlink h) {
        this.lnkAnalisesAcidente = h;
    }

    private HiddenField hidDisableImprimir = new HiddenField();

    public HiddenField getHidDisableImprimir() {
        return hidDisableImprimir;
    }

    public void setHidDisableImprimir(HiddenField hf) {
        this.hidDisableImprimir = hf;
    }

    private DropDown drpSeccao = new DropDown();

    public DropDown getDrpSeccao() {
        return drpSeccao;
    }

    public void setDrpSeccao(DropDown dd) {
        this.drpSeccao = dd;
    }

    private StaticText staticText163 = new StaticText();

    public StaticText getStaticText163() {
        return staticText163;
    }

    public void setStaticText163(StaticText st) {
        this.staticText163 = st;
    }

    private DropDown drpDepartamento = new DropDown();

    public DropDown getDrpDepartamento() {
        return drpDepartamento;
    }

    public void setDrpDepartamento(DropDown dd) {
        this.drpDepartamento = dd;
    }

    private HiddenField hidAnchor = new HiddenField();

    public HiddenField getHidAnchor() {
        return hidAnchor;
    }

    public void setHidAnchor(HiddenField hf) {
        this.hidAnchor = hf;
    }

    private PanelGroup groupPanel62 = new PanelGroup();

    public PanelGroup getGroupPanel62() {
        return groupPanel62;
    }

    public void setGroupPanel62(PanelGroup pg) {
        this.groupPanel62 = pg;
    }

    private StaticText staticText164 = new StaticText();

    public StaticText getStaticText164() {
        return staticText164;
    }

    public void setStaticText164(StaticText st) {
        this.staticText164 = st;
    }

    private StaticText staticText167 = new StaticText();

    public StaticText getStaticText167() {
        return staticText167;
    }

    public void setStaticText167(StaticText st) {
        this.staticText167 = st;
    }

    private PanelGroup groupPanel63 = new PanelGroup();

    public PanelGroup getGroupPanel63() {
        return groupPanel63;
    }

    public void setGroupPanel63(PanelGroup pg) {
        this.groupPanel63 = pg;
    }

    private StaticText staticText171 = new StaticText();

    public StaticText getStaticText171() {
        return staticText171;
    }

    public void setStaticText171(StaticText st) {
        this.staticText171 = st;
    }

    private StaticText stTecnicoNome = new StaticText();

    public StaticText getStTecnicoNome() {
        return stTecnicoNome;
    }

    public void setStTecnicoNome(StaticText st) {
        this.stTecnicoNome = st;
    }

    private StaticText staticText172 = new StaticText();

    public StaticText getStaticText172() {
        return staticText172;
    }

    public void setStaticText172(StaticText st) {
        this.staticText172 = st;
    }

    private StaticText staticText173 = new StaticText();

    public StaticText getStaticText173() {
        return staticText173;
    }

    public void setStaticText173(StaticText st) {
        this.staticText173 = st;
    }

    private StaticText txtCap1 = new StaticText();

    public StaticText getTxtCap1() {
        return txtCap1;
    }

    public void setTxtCap1(StaticText st) {
        this.txtCap1 = st;
    }

    private PanelGroup groupPanel64 = new PanelGroup();

    public PanelGroup getGroupPanel64() {
        return groupPanel64;
    }

    public void setGroupPanel64(PanelGroup pg) {
        this.groupPanel64 = pg;
    }

    private StaticText staticText174 = new StaticText();

    public StaticText getStaticText174() {
        return staticText174;
    }

    public void setStaticText174(StaticText st) {
        this.staticText174 = st;
    }

    private StaticText stMedicoNome = new StaticText();

    public StaticText getStMedicoNome() {
        return stMedicoNome;
    }

    public void setStMedicoNome(StaticText st) {
        this.stMedicoNome = st;
    }

    private StaticText staticText175 = new StaticText();

    public StaticText getStaticText175() {
        return staticText175;
    }

    public void setStaticText175(StaticText st) {
        this.staticText175 = st;
    }

    private StaticText staticText176 = new StaticText();

    public StaticText getStaticText176() {
        return staticText176;
    }

    public void setStaticText176(StaticText st) {
        this.staticText176 = st;
    }

    private StaticText txtCedula1 = new StaticText();

    public StaticText getTxtCedula1() {
        return txtCedula1;
    }

    public void setTxtCedula1(StaticText st) {
        this.txtCedula1 = st;
    }

    private HtmlPanelGrid gridPanel14 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel14() {
        return gridPanel14;
    }

    public void setGridPanel14(HtmlPanelGrid hpg) {
        this.gridPanel14 = hpg;
    }

    private StaticText staticText15 = new StaticText();

    public StaticText getStaticText15() {
        return staticText15;
    }

    public void setStaticText15(StaticText st) {
        this.staticText15 = st;
    }

    private com.sun.rave.web.ui.component.Calendar calDataOcorrencia = new com.sun.rave.web.ui.component.Calendar();

    public com.sun.rave.web.ui.component.Calendar getCalDataOcorrencia() {
        return calDataOcorrencia;
    }

    public void setCalDataOcorrencia(com.sun.rave.web.ui.component.Calendar c) {
        this.calDataOcorrencia = c;
    }

    private PanelGroup groupPanel9 = new PanelGroup();

    public PanelGroup getGroupPanel9() {
        return groupPanel9;
    }

    public void setGroupPanel9(PanelGroup pg) {
        this.groupPanel9 = pg;
    }

    private StaticText staticText71 = new StaticText();

    public StaticText getStaticText71() {
        return staticText71;
    }

    public void setStaticText71(StaticText st) {
        this.staticText71 = st;
    }

    private DropDown drpHours = new DropDown();

    public DropDown getDrpHours() {
        return drpHours;
    }

    public void setDrpHours(DropDown dd) {
        this.drpHours = dd;
    }

    private StaticText staticText72 = new StaticText();

    public StaticText getStaticText72() {
        return staticText72;
    }

    public void setStaticText72(StaticText st) {
        this.staticText72 = st;
    }

    private DropDown drpMinutes = new DropDown();

    public DropDown getDrpMinutes() {
        return drpMinutes;
    }

    public void setDrpMinutes(DropDown dd) {
        this.drpMinutes = dd;
    }

    private PanelGroup groupPanel8 = new PanelGroup();

    public PanelGroup getGroupPanel8() {
        return groupPanel8;
    }

    public void setGroupPanel8(PanelGroup pg) {
        this.groupPanel8 = pg;
    }

    private StaticText staticText14 = new StaticText();

    public StaticText getStaticText14() {
        return staticText14;
    }

    public void setStaticText14(StaticText st) {
        this.staticText14 = st;
    }

    private StaticText stNomeAcidentado = new StaticText();

    public StaticText getStNomeAcidentado() {
        return stNomeAcidentado;
    }

    public void setStNomeAcidentado(StaticText st) {
        this.stNomeAcidentado = st;
    }

    private PanelGroup groupPanel15 = new PanelGroup();

    public PanelGroup getGroupPanel15() {
        return groupPanel15;
    }

    public void setGroupPanel15(PanelGroup pg) {
        this.groupPanel15 = pg;
    }

    private StaticText staticText70 = new StaticText();

    public StaticText getStaticText70() {
        return staticText70;
    }

    public void setStaticText70(StaticText st) {
        this.staticText70 = st;
    }

    private StaticText stEstabelecimentoOrigem1 = new StaticText();

    public StaticText getStEstabelecimentoOrigem1() {
        return stEstabelecimentoOrigem1;
    }

    public void setStEstabelecimentoOrigem1(StaticText st) {
        this.stEstabelecimentoOrigem1 = st;
    }

    private PanelGroup groupPanel16 = new PanelGroup();

    public PanelGroup getGroupPanel16() {
        return groupPanel16;
    }

    public void setGroupPanel16(PanelGroup pg) {
        this.groupPanel16 = pg;
    }

    private StaticText staticText74 = new StaticText();

    public StaticText getStaticText74() {
        return staticText74;
    }

    public void setStaticText74(StaticText st) {
        this.staticText74 = st;
    }

    private StaticText stDataNascimento = new StaticText();

    public StaticText getStDataNascimento() {
        return stDataNascimento;
    }

    public void setStDataNascimento(StaticText st) {
        this.stDataNascimento = st;
    }

    private PanelGroup groupPanel65 = new PanelGroup();

    public PanelGroup getGroupPanel65() {
        return groupPanel65;
    }

    public void setGroupPanel65(PanelGroup pg) {
        this.groupPanel65 = pg;
    }

    private StaticText staticText75 = new StaticText();

    public StaticText getStaticText75() {
        return staticText75;
    }

    public void setStaticText75(StaticText st) {
        this.staticText75 = st;
    }

    private StaticText stBI = new StaticText();

    public StaticText getStBI() {
        return stBI;
    }

    public void setStBI(StaticText st) {
        this.stBI = st;
    }

    private PanelGroup groupPanel66 = new PanelGroup();

    public PanelGroup getGroupPanel66() {
        return groupPanel66;
    }

    public void setGroupPanel66(PanelGroup pg) {
        this.groupPanel66 = pg;
    }

    private StaticText staticText77 = new StaticText();

    public StaticText getStaticText77() {
        return staticText77;
    }

    public void setStaticText77(StaticText st) {
        this.staticText77 = st;
    }

    private StaticText stMorada = new StaticText();

    public StaticText getStMorada() {
        return stMorada;
    }

    public void setStMorada(StaticText st) {
        this.stMorada = st;
    }

    private StaticText staticText79 = new StaticText();

    public StaticText getStaticText79() {
        return staticText79;
    }

    public void setStaticText79(StaticText st) {
        this.staticText79 = st;
    }

    private StaticText stCodPostal = new StaticText();

    public StaticText getStCodPostal() {
        return stCodPostal;
    }

    public void setStCodPostal(StaticText st) {
        this.stCodPostal = st;
    }

    private PanelGroup groupPanel67 = new PanelGroup();

    public PanelGroup getGroupPanel67() {
        return groupPanel67;
    }

    public void setGroupPanel67(PanelGroup pg) {
        this.groupPanel67 = pg;
    }

    private StaticText staticText80 = new StaticText();

    public StaticText getStaticText80() {
        return staticText80;
    }

    public void setStaticText80(StaticText st) {
        this.staticText80 = st;
    }

    private StaticText stContactoTelefonico = new StaticText();

    public StaticText getStContactoTelefonico() {
        return stContactoTelefonico;
    }

    public void setStContactoTelefonico(StaticText st) {
        this.stContactoTelefonico = st;
    }

    private PanelGroup groupPanel68 = new PanelGroup();

    public PanelGroup getGroupPanel68() {
        return groupPanel68;
    }

    public void setGroupPanel68(PanelGroup pg) {
        this.groupPanel68 = pg;
    }

    private StaticText staticText81 = new StaticText();

    public StaticText getStaticText81() {
        return staticText81;
    }

    public void setStaticText81(StaticText st) {
        this.staticText81 = st;
    }

    private StaticText stDataAdmissao1 = new StaticText();

    public StaticText getStDataAdmissao1() {
        return stDataAdmissao1;
    }

    public void setStDataAdmissao1(StaticText st) {
        this.stDataAdmissao1 = st;
    }

    private PanelGroup groupPanel69 = new PanelGroup();

    public PanelGroup getGroupPanel69() {
        return groupPanel69;
    }

    public void setGroupPanel69(PanelGroup pg) {
        this.groupPanel69 = pg;
    }

    private StaticText staticText82 = new StaticText();

    public StaticText getStaticText82() {
        return staticText82;
    }

    public void setStaticText82(StaticText st) {
        this.staticText82 = st;
    }

    private StaticText stFuncao1 = new StaticText();

    public StaticText getStFuncao1() {
        return stFuncao1;
    }

    public void setStFuncao1(StaticText st) {
        this.stFuncao1 = st;
    }

    private PanelGroup groupPanel70 = new PanelGroup();

    public PanelGroup getGroupPanel70() {
        return groupPanel70;
    }

    public void setGroupPanel70(PanelGroup pg) {
        this.groupPanel70 = pg;
    }

    private StaticText staticText83 = new StaticText();

    public StaticText getStaticText83() {
        return staticText83;
    }

    public void setStaticText83(StaticText st) {
        this.staticText83 = st;
    }

    private StaticText stTurno = new StaticText();

    public StaticText getStTurno() {
        return stTurno;
    }

    public void setStTurno(StaticText st) {
        this.stTurno = st;
    }

    private PanelGroup groupPanel71 = new PanelGroup();

    public PanelGroup getGroupPanel71() {
        return groupPanel71;
    }

    public void setGroupPanel71(PanelGroup pg) {
        this.groupPanel71 = pg;
    }

    private StaticText staticText84 = new StaticText();

    public StaticText getStaticText84() {
        return staticText84;
    }

    public void setStaticText84(StaticText st) {
        this.staticText84 = st;
    }

    private StaticText staticText85 = new StaticText();

    public StaticText getStaticText85() {
        return staticText85;
    }

    public void setStaticText85(StaticText st) {
        this.staticText85 = st;
    }

    private PanelGroup groupPanel72 = new PanelGroup();

    public PanelGroup getGroupPanel72() {
        return groupPanel72;
    }

    public void setGroupPanel72(PanelGroup pg) {
        this.groupPanel72 = pg;
    }

    private StaticText staticText86 = new StaticText();

    public StaticText getStaticText86() {
        return staticText86;
    }

    public void setStaticText86(StaticText st) {
        this.staticText86 = st;
    }

    private StaticText stMedico = new StaticText();

    public StaticText getStMedico() {
        return stMedico;
    }

    public void setStMedico(StaticText st) {
        this.stMedico = st;
    }

    private StaticText staticText87 = new StaticText();

    public StaticText getStaticText87() {
        return staticText87;
    }

    public void setStaticText87(StaticText st) {
        this.staticText87 = st;
    }

    private StaticText staticText92 = new StaticText();

    public StaticText getStaticText92() {
        return staticText92;
    }

    public void setStaticText92(StaticText st) {
        this.staticText92 = st;
    }

    private StaticText txtCedula = new StaticText();

    public StaticText getTxtCedula() {
        return txtCedula;
    }

    public void setTxtCedula(StaticText st) {
        this.txtCedula = st;
    }

    private PanelGroup groupPanel4 = new PanelGroup();

    public PanelGroup getGroupPanel4() {
        return groupPanel4;
    }

    public void setGroupPanel4(PanelGroup pg) {
        this.groupPanel4 = pg;
    }

    private StaticText staticText7 = new StaticText();

    public StaticText getStaticText7() {
        return staticText7;
    }

    public void setStaticText7(StaticText st) {
        this.staticText7 = st;
    }

    private TextField txtHorasTurno = new TextField();

    public TextField getTxtHorasTurno() {
        return txtHorasTurno;
    }

    public void setTxtHorasTurno(TextField tf) {
        this.txtHorasTurno = tf;
    }

    private Hyperlink lnkAjuda1 = new Hyperlink();

    public Hyperlink getLnkAjuda1() {
        return lnkAjuda1;
    }

    public void setLnkAjuda1(Hyperlink h) {
        this.lnkAjuda1 = h;
    }

    private StaticText staticText8 = new StaticText();

    public StaticText getStaticText8() {
        return staticText8;
    }

    public void setStaticText8(StaticText st) {
        this.staticText8 = st;
    }

    private HiddenField hidConfEnviar = new HiddenField();

    public HiddenField getHidConfEnviar() {
        return hidConfEnviar;
    }

    public void setHidConfEnviar(HiddenField hf) {
        this.hidConfEnviar = hf;
    }
    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public AnaliseAcidenteTrabalho() {
    }
    
    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     *
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here
        
        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("AnaliseAcidenteTrabalho Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
        }
        
        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
        
	if (!getSessionBean1().isLoggedIn()) {
	    try {
		getExternalContext().redirect("Login.jsp");
	    } catch(Exception e) {  
	    // . . .  handle exception . . .              
	    }
	}
        else
        {
            
               initCalendars();

               HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest();
               String referer = request.getRequestURI();
               String pageFrom = Utils.getPageFrom(referer);
               if(!pageFrom.matches("AnaliseAcidenteTrabalho.jsp"))
               {    
                    if(pageFrom.matches("LoadImage.jsp"))
                    {
                        restorePageState();
                        //if(getSessionBean1().getImageName() != null)
                        //{
                            fillImages();                    
                        //}
                    }
                    else    
                    {
                        String tmpImageFolder = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin();
                        File tmpFolder = new File(tmpImageFolder);
                        if(tmpFolder.exists())
                        {
                            Global global = new Global();
                            global.deleteFolderFiles(tmpFolder);
                            tmpFolder.delete();
                        }

                        lblUser.setText( getSessionBean1().getCurrentUser().getLogin() ); 
                        getSessionBean1().setGravado(false);
                        getSessionBean1().setSubmetido(false);   
                        getSessionBean1().setIeBug(false);
                        //drpTecnicos.setSelected(new Integer(0));
                        //drpMedicos.setSelected(new Integer(0));                
                        if(getSessionBean1().getCurrentAnalise() == null) // new analise
                        {
                            getSessionBean1().setAcidentado(null);  // Here ?????
                            lnkLblTrabalhador.setDisabled(true);
                            lnkLblTrabalhador.setStyleClass("");
                            initializePage();                                    
                        }
                        else    // edit analise
                        {
                            lnkLblTrabalhador.setDisabled(false);                    
                            lnkLblTrabalhador.setStyleClass("labelTrabalhador");                    
                            gridTrabalhadores.setRendered(false); 

                            fillPage();                    
                        }

                    }
               } 
            
        }
        

    }
    
    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    public void preprocess() {
    }
    
    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    public void prerender() {
       txtMsg.setText(getSessionBean1().getMsg());
       getSessionBean1().setMsg("");
       
    }
    
    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    public void destroy() {

    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1)getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1)getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1)getBean("ApplicationBean1");
    }

    public String lnkLogout_action() {
        // TODO: Replace with your code
        getSessionBean1().setIeBug(true);                
        try
        {
            javax.servlet.http.HttpSession session =
                    (javax.servlet.http.HttpSession) getExternalContext().getSession(true);
            session.invalidate();            
        }
        catch(Exception ex){}

	    try {
		getExternalContext().redirect("Login.jsp");
	    } catch(Exception e) {}        
        //return "login";	
        return null;
    }
    
    
    private void initializePage()
    {
       hidAnchor.setValue("none");
       butCorrecao.setRendered(false);
       butGravar.setText("Gravar");
       butEnviar.setText("Enviar a RH");  
       gridSiprp.setRendered(false);
       //gridAcidentadoView.setRendered(false);
       gridSiprpView.setRendered(false);
       gridAcidentadoView.setRendered(false);
       gridDadosAcidenteRh.setRendered(false);
       gridDadosAcidenteRhView.setRendered(false);
       gridRecomendacoesHS.setRendered(false);    
       gridRecomendacoesViewHS.setRendered(false);  
       gridMedidasRH.setRendered(false);
       gridMedidasViewRH.setRendered(false);
       gridMedico.setRendered(false);
       gridMedicoView.setRendered(false); 
       gridVerificacao.setRendered(false);
       gridVerificacaoView.setRendered(false); 
       gridImpressao.setRendered(false);
       gridImpressaoView.setRendered(false);              
       
       tblTrabalhadores.setRendered(false);
       gridAcidentado.setRendered(false);
       gridDadosAcidenteSeg.setRendered(false);
       gridDadosAcidenteSegView.setRendered(false); 
       
       butImprimir.setRendered(false);
       
       AnalisesDataProvider adp = new AnalisesDataProvider();
       try
       {
           String nome_empresa = adp.getEmpresaNome(getSessionBean1().getCurrentUser().getEmpresa_id());
            txtEmpresa.setText(utils.Utils.unicodeToHTML(nome_empresa));
       }
       catch(Exception ex)
       {
           ex.printStackTrace();
       }       
       try
       {
            txtEstabelecimento.setText(adp.getEstabelecimentoNome(getSessionBean1().getCurrentUser().getEstabelecimento_id()));
       }
       catch(Exception ex)
       {
           ex.printStackTrace();
       }
       

       drpDepartamento.setSelected(new Integer(0));
       try
       {
            getSessionBean1().setSeccaoOptions(adp.getSeccoesList(null));               
            drpSeccao.setSelected(new Integer(0));
       }
       catch(Exception ex)
       {
           ex.printStackTrace();
       }            
       
       
//       fillTrabalhadoresTable();

//       Calendar c = Calendar.getInstance();
//       SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
//       stDataAcidente.setText(dateFormat.format(c.getTime()));
        txtAveriguador.setText( getSessionBean1().getCurrentUser().getNome() );
        java.util.Date today =
                        new java.util.Date();
        calDataOcorrencia.setValue(today);       
        
        //drpMedicos.setSelected(new Integer(0));
        UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
        Medico m = udp.getMedico( getSessionBean1().getCurrentUser().getEstabelecimento_id() );
        getSessionBean1().setMedico( m );
        if(m != null)
        {
            stMedico.setText(m.getNome() + "&nbsp;&nbsp;");
            txtCedula.setText(m.getNumero_cedula());        
        }
        drpHours.setSelected(new Integer(-1));
        drpMinutes.setSelected(new Integer(-1));   
        drpDepartamento.setSelected(new Integer(0));
        drpSeccao.setSelected(new Integer(0));
        drpCausas.setSelected(new Integer(0));
    }
    
//    private void fillTrabalhadoresTable()
//    {
//       AnalisesDataProvider adp = new AnalisesDataProvider();        
//       try
//       {
//            //lblActivos.setRendered(true);
//            table1.setRendered(true);                                      
//
//            ArrayList trabalhadoresList = adp.getTrabalhadoresListByEstabelecimento(getSessionBean1().getCurrentUser().getEstabelecimento_id());
//            getSessionBean1().getTrabalhadoresListDataProvider().setList(trabalhadoresList);
//       }
//       catch(Exception ex)
//       {
//           //lblActivos.setRendered(false);
//           table1.setRendered(false);                   
//           ex.printStackTrace();
//       }                                
//    }
    
    private String fillPage()
    {
        AnaliseAcidente a = getSessionBean1().getCurrentAnalise();   
        
        //correcao
        if(a.getCorrecao().matches("y"))
        {
            stObservacoesCorr.setText(a.getObservacoes_correcao());
        }
        else
        {
            stObservacoesCorr.setRendered(false);
        }
        
        
        stHeaderNr.setText(a.getAnalise_nr());
        try
        {
            java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime());
            stHeaderDate.setText(utils.Utils.dateToYYYYMMDD(ddate));            
        }
        catch(Exception ex){};                                                
        AnalisesDataProvider adp = new AnalisesDataProvider();
        try
        {
            String nome_empresa = adp.getEmpresaNome(a.getEmpresa_id());
            txtEmpresa.setText(utils.Utils.unicodeToHTML(nome_empresa));
        }
        catch(Exception ex)
        {
           ex.printStackTrace();
        }                 
        try
        {
            txtEstabelecimento.setText(adp.getEstabelecimentoNome(a.getEstabelecimento_id()));
        }
        catch(Exception ex)
        {
           ex.printStackTrace();
        }         
        
        Acidentado ac = null;
        try
        {
            //Trabalhador t = adp.getTrabalhador(a.getTrabalhador_id());
            //txtDataNascimento.setText(t.getData_nascimento());   
            ac = adp.getAcidentado(a.getAcidentado_id());
            txtTrabalhador.setText(ac.getNome());
            getSessionBean1().setAcidentado(ac);
        }
        catch(Exception ex)
        {
           ex.printStackTrace();
        }  
        
       
        int estado_documento = a.getEstado().intValue();
//        if(estado_documento != Global.ESTADO_IMPRESSAO)
////        if(estado_documento != Global.ESTADO_ASSINATURAS || (estado_documento == Global.ESTADO_ASSINATURAS && getSessionBean1().getCurrentUser().getTipo().intValue() != Global.TIPO_UTILIZADOR_RH))        
////        {
////            butImprimir.setRendered(false);
////        }
////        else
////        {
////            butGravar.setRendered(false);
////        }
        butImprimir.setRendered(false);
        
        if(estado_documento > Global.ESTADO_SEG && getSessionBean1().getCurrentUser().getTipo().intValue() == 1 && a.getAveriguacao_posterior().matches("y"))
        {
           boolean booAveriguacao = false;
           if(a.getAveriguacao_obs() == null)  
           {
               booAveriguacao = true;
           }
           else if(a.getAveriguacao_obs().trim().length() == 0)
           {
               booAveriguacao = true;               
           }
           if(booAveriguacao)
           {
               butCorrecao.setRendered(false);
               butGravar.setText("Gravar"); 
               butEnviar.setRendered(false);
               gridSiprp.setRendered(false);           
               //gridSiprpView.setRendered(false);
               gridAcidentado.setRendered(false);   //19/11/2007
               gridAcidentadoView.setRendered(false); //19/11/2007
               gridDadosAcidenteSeg.setRendered(false); //19/11/2007           
               //gridDadosAcidenteSegView.setRendered(false); //19/11/2007               
               gridDadosAcidenteRh.setRendered(false);
               gridDadosAcidenteRhView.setRendered(false);
               gridRecomendacoesHS.setRendered(false); 
               gridRecomendacoesViewHS.setRendered(false);  
               gridMedidasRH.setRendered(false);
               gridMedidasViewRH.setRendered(false);    
               gridMedico.setRendered(false);
               gridMedicoView.setRendered(false);
               gridVerificacao.setRendered(false);
               gridVerificacaoView.setRendered(false); 
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);  

    //           fillSiprp(a);
    //           fillDadosAcidenteSegView(a); 
               fillSiprpView(a);
               if(ac != null)
               {
                    fillAcidentadoView(ac);                   
               }
               fillDadosAcidenteSegView(a);                            

               return null;               
           }

        }
        
        
        switch(estado_documento)
        {
            case Global.ESTADO_SEG:
               butCorrecao.setRendered(false);
               butGravar.setText("Gravar"); 
               if(a.getCorrecao().matches("y"))
               {
                   butEnviar.setText("Enviar a Recomendações SHST");                    
               }
               else
               {
                    butEnviar.setText("Enviar a Acompanhamento RH");                                    
               }
               gridSiprpView.setRendered(false);
               gridAcidentado.setRendered(false);   //19/11/2007
               //gridAcidentadoView.setRendered(false); //19/11/2007
               gridDadosAcidenteSegView.setRendered(false); //19/11/2007               
               gridDadosAcidenteRh.setRendered(false);
               gridDadosAcidenteRhView.setRendered(false);
               gridRecomendacoesHS.setRendered(false); 
               gridRecomendacoesViewHS.setRendered(false);  
               gridMedidasRH.setRendered(false);
               gridMedidasViewRH.setRendered(false);    
               gridMedico.setRendered(false);
               gridMedicoView.setRendered(false);
               gridVerificacao.setRendered(false);
               gridVerificacaoView.setRendered(false); 
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);                             
               
               fillSiprp(a);               
               fillAcidentadoView(ac);
               fillDadosAcidenteSeg(a);
               break;
            case Global.ESTADO_RH1:  
               butCorrecao.setRendered(false);                
               butGravar.setText("Gravar");                                   
               butEnviar.setText("Enviar a Recomendações SHST"); 
               gridSiprpView.setRendered(false);
               gridAcidentadoView.setRendered(false);
               gridDadosAcidenteSeg.setRendered(false); //19/11/2007
               gridDadosAcidenteRhView.setRendered(false);
               gridRecomendacoesHS.setRendered(false); 
               gridRecomendacoesViewHS.setRendered(false);  
               gridMedidasRH.setRendered(false);
               gridMedidasViewRH.setRendered(false);  
               gridMedico.setRendered(false); 
               gridMedicoView.setRendered(false);  
               gridVerificacao.setRendered(false);
               gridVerificacaoView.setRendered(false);   
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);                                            
               
               if(ac != null)
               {
                    fillAcidentado(ac);                   
               }
               fillSiprp(a);
               fillDadosAcidenteSegView(a);               
               fillDadosAcidenteRh(a);
               break;
            case Global.ESTADO_HS:  
               butGravar.setText("Gravar");    
               butEnviar.setText("Enviar a Medidas RH");                 
               //gridSiprpView.setRendered(false);
               gridSiprp.setRendered(false);
               gridAcidentado.setRendered(false);
               //gridAcidentadoView.setRendered(false);
               gridDadosAcidenteSeg.setRendered(false);               
               gridDadosAcidenteRh.setRendered(false);
               gridRecomendacoesViewHS.setRendered(false);   
               gridMedidasRH.setRendered(false);
               gridMedidasViewRH.setRendered(false);     
               gridMedico.setRendered(false); 
               gridMedicoView.setRendered(false);  
               gridVerificacao.setRendered(false);
               gridVerificacaoView.setRendered(false);     
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);                                            
               
               fillSiprpView(a);
               if(ac != null)
               {
                    fillAcidentadoView(ac);                   
               }
               fillDadosAcidenteSegView(a);                 
               fillDadosAcidenteRhView(a);
               fillRecomendacoesHs(a);
               //gridDadosAcidenteRhView.setRendered(false);
               //gridRecomendacoesHS.setRendered(false); 
               break;
            case Global.ESTADO_RH2:
               butCorrecao.setRendered(false);                
               butGravar.setText("Gravar");                                   
               //butEnviar.setText("Enviar a M&eacute;dico");
//               if(a.getCorrecao().matches("y"))
//               {
//                   butEnviar.setText("Enviar a Consolidação");
//               }
//               else
//               {
//                    butEnviar.setText("Enviar a Medicina");                                    
//               }     
               butEnviar.setText("Enviar a Consolidação");               
               
               //butEnviar.setText("Enviar a Medicina");                   
               //gridSiprpView.setRendered(false);
               gridSiprp.setRendered(false);
               gridAcidentado.setRendered(false);
               //gridAcidentadoView.setRendered(false);
               gridDadosAcidenteSeg.setRendered(false);               
               gridDadosAcidenteRh.setRendered(false);
               gridRecomendacoesHS.setRendered(false);
               //gridRecomendacoesViewHS.setRendered(false);   
               gridMedidasViewRH.setRendered(false);   
               //gridMedico.setRendered(false);  
               gridMedicoView.setRendered(false);  
               gridVerificacao.setRendered(false);
               gridVerificacaoView.setRendered(false); 
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);                                            
               
               fillSiprpView(a);
               if(ac != null)
               {
                    fillAcidentadoView(ac);                   
               }
               fillDadosAcidenteSegView(a);                 
               fillDadosAcidenteRhView(a);
               fillRecomendacoesViewHs(a);
               //fillMedico(a);   //19/11/2007
               fillMedidasRh(a);
               fillMedico(a);   //23/11/2007                              
               break;
//            case Global.ESTADO_MEDICINA:   
//               butCorrecao.setRendered(false);                
//               butGravar.setText("Gravar");                                   
//               butEnviar.setText("Enviar a Consolidação");                   
//               //gridSiprpView.setRendered(false);
//               gridSiprp.setRendered(false);
//               gridAcidentado.setRendered(false);
//               //gridAcidentadoView.setRendered(false);
//               gridDadosAcidenteSeg.setRendered(false);               
//               gridDadosAcidenteRh.setRendered(false);
//               gridRecomendacoesHS.setRendered(false);
//               //gridRecomendacoesViewHS.setRendered(false);   
//               gridMedidasRH.setRendered(false);                  
//               //gridMedidasViewRH.setRendered(false);   
//               //gridMedico.setRendered(false);  
//               gridMedicoView.setRendered(false);  
//               gridVerificacao.setRendered(false);
//               gridVerificacaoView.setRendered(false); 
//               gridImpressao.setRendered(false);
//               gridImpressaoView.setRendered(false);                                            
//               
//               fillSiprpView(a);
//               if(ac != null)
//               {
//                    fillAcidentadoView(ac);                   
//               }
//               fillDadosAcidenteSegView(a);                 
//               fillDadosAcidenteRhView(a);
//               fillRecomendacoesViewHs(a);
//               fillMedidasViewRh(a);
//               fillMedico(a);   //23/11/2007               
//               break;
            case Global.ESTADO_CONSOLIDACAO:   
               //butGravar.setText("Gravar");  
               butGravar.setRendered(false);
               butEnviar.setText("Enviar a Verificação");
               hidDisableEnviar.setValue("n");      
               boolean booAveriguacao = false;
               if(a.getAveriguacao_posterior().matches("y"))
               {
                   if(a.getAveriguacao_obs() == null)
                   {
                       booAveriguacao = true;
                   }
                   else if(a.getAveriguacao_obs().trim().length() == 0)
                   {
                       booAveriguacao = true;                       
                   }
                   if(booAveriguacao)
                   {
                        hidDisableEnviar.setValue("y");                       
                   }

               }
               gridSiprp.setRendered(false);
               gridAcidentado.setRendered(false);
               //gridAcidentadoView.setRendered(false);
               gridDadosAcidenteSeg.setRendered(false);               
               gridDadosAcidenteRh.setRendered(false);
               gridRecomendacoesHS.setRendered(false);
               //gridRecomendacoesViewHS.setRendered(false);   
               gridMedidasRH.setRendered(false);                  
               //gridMedidasViewRH.setRendered(false);   
               gridMedico.setRendered(false);  
               //gridMedicoView.setRendered(false);  
               //gridVerificacao.setRendered(false);
               java.util.Date ddate = new java.util.Date();
               stVerHs.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate));
               grpVerRespSeg.setRendered(false);
               grpVerRespRh.setRendered(false);    
               butGravar.setDisabled(true);               
               butEnviar.setDisabled(true);
               gridVerificacaoView.setRendered(false);   
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);                                            
               
               fillSiprpView(a);
               if(ac != null)
               {
                    fillAcidentadoView(ac);                   
               }
               fillDadosAcidenteSegView(a);                 
               fillDadosAcidenteRhView(a);
               fillRecomendacoesViewHs(a);
               fillMedidasViewRh(a);
               fillMedicoView(a);   //23/11/2007                              
                break;
            case Global.ESTADO_ASSINATURA_SEG:
               butImprimir.setRendered(false);
               butCorrecao.setRendered(false);                
               butEnviar.setText("Enviar a RH");                 
               //butGravar.setText("Enviar");
               butGravar.setRendered(false);
               gridSiprp.setRendered(false);
               gridAcidentado.setRendered(false);
               gridDadosAcidenteSeg.setRendered(false);
               gridDadosAcidenteRh.setRendered(false);
               gridRecomendacoesHS.setRendered(false); 
               gridRecomendacoesViewHS.setRendered(false);  
               gridMedidasRH.setRendered(false);
               //gridMedidasViewRH.setRendered(false);    
               gridMedico.setRendered(false);
               //gridMedicoView.setRendered(false);
               //gridVerificacaoView.setRendered(false); 
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);                                                    
               grpVerRespSeg.setRendered(true);                       
               grpVerHs.setRendered(false);
               grpVerRespRh.setRendered(false);
               //chkVerRespRh.setDisabled(true);
               ddate = new java.util.Date();
               stVerRespSeg.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate));                
               
               fillSiprpView(a);
               if(ac != null)
               {
                    fillAcidentadoView(ac);                   
               }
               fillDadosAcidenteSegView(a);                        
               fillDadosAcidenteRhView(a);
               fillMedidasViewRh(a);                         
               fillMedicoView(a); 
               fillVerificacaoView(a);               
               fillVerificacao(a);
               
                break;
            case Global.ESTADO_ASSINATURA_RH:
               butGravar.setRendered(false);
                //butGravar.setText("Imprimir");
                butCorrecao.setRendered(false);                                
                butImprimir.setRendered(false);
               butEnviar.setText("Enviar a Conclusão");                                 
               gridSiprp.setRendered(false);
               gridAcidentado.setRendered(false);
               gridDadosAcidenteSeg.setRendered(false);               
               gridDadosAcidenteRh.setRendered(false);
               gridRecomendacoesHS.setRendered(false);
               gridMedidasRH.setRendered(false);   
               gridMedico.setRendered(false);  
               //gridMedicoView.setRendered(false); 
               //gridVerificacaoView.setRendered(false);  
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);                                                    
               grpVerRespRh.setRendered(true);
               grpVerHs.setRendered(false);    
               grpVerRespSeg.setRendered(false);
               //chkVerRespSeg.setDisabled(true); 
               ddate = new java.util.Date();
               stVerRespRh.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate));

               fillSiprpView(a);
               if(ac != null)
               {
                    fillAcidentadoView(ac);                   
               }
               fillDadosAcidenteSegView(a);                        
               fillDadosAcidenteRhView(a);
               fillRecomendacoesViewHs(a);
               fillMedidasViewRh(a);  
               fillMedicoView(a);  
               fillVerificacaoView(a);               
               fillVerificacao(a);               
                break;

            case Global.ESTADO_FECHAR:
               butCorrecao.setRendered(false);
               butGravar.setRendered(false);
               butGravar.setText("Gravar");                                   
               butEnviar.setText("Fechar");                 
               gridSiprp.setRendered(false);
               gridAcidentado.setRendered(false);     
               gridDadosAcidenteSeg.setRendered(false);               
               gridDadosAcidenteRh.setRendered(false);
               gridRecomendacoesHS.setRendered(false);               
               gridMedidasRH.setRendered(false);  
               gridMedico.setRendered(false);   
               gridVerificacao.setRendered(false);   
               gridImpressao.setRendered(false);
               gridImpressaoView.setRendered(false);               
               fillSiprpView(a);
               if(ac != null)
               {
                    fillAcidentadoView(ac);                   
               }
               fillDadosAcidenteSegView(a);                
               fillDadosAcidenteRhView(a);
               fillRecomendacoesViewHs(a);
               fillMedidasViewRh(a);    
               //fillMedico(a);
               fillMedicoView(a);  
               fillVerificacaoView(a);
               //fillImpressaoView(a);
               break;                                                                              
            case Global.ESTADO_CONCLUIDO:
        }
        
        return null;
    }
    
    private void fillSiprp(AnaliseAcidente a)
    {
        //drpTecnicos.setSelected(a.getTecnico_saude_id());
        //drpMedicos.setSelected(a.getMedico_id());
        UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
        try
        {
            Utilizador u = udp.getUtilizador(a.getTecnico_saude_id());                
            txtCap.setText(u.getCap());
        }
        catch(Exception ex)
        {
            //ex.printStackTrace();
        }                            
        try
        {
            Utilizador u = udp.getUtilizador(a.getMedico_id()); 
            stMedico.setText(u.getNome() + "&nbsp;&nbsp;");
            txtCedula.setText(u.getNumero_cedula());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }                    
    }    
    
    private void fillSiprpView(AnaliseAcidente a)
    {
        UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
    
        if(a.getEstado().intValue() == Global.ESTADO_HS)
        {
            if(a.getTecnico_saude_id().equals(new Integer(0)))
            {
                a.setTecnico_saude_id( getSessionBean1().getCurrentUser().getId());
            }
        }
        
        try
        {
            Utilizador u = udp.getUtilizador(a.getTecnico_saude_id());   
            stTecnicoNome.setText(Utils.unicodeToHTML(u.getNome()));
            txtCap1.setText(u.getCap());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }                            
        try
        {
            Utilizador u = udp.getUtilizador(a.getMedico_id()); 
            stMedicoNome.setText(Utils.unicodeToHTML(u.getNome()));            
            txtCedula1.setText(u.getNumero_cedula());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }                            
    }
    
    private void fillAcidentado(Acidentado a)
    {
        txtNomeAcidentado.setText(a.getNome());     
        stEstabelecimentoOrigem.setText(a.getEstabelecimento_origem());
        //txtDataNascimento.setText(a.getData_nascimento());                       
        try
        {
            java.util.Date ddate = new java.util.Date(a.getData_nascimento().getTime());
            txtDataNascimento.setText(utils.Utils.dateToYYYYMMDD(ddate));            
        }  
        catch(Exception ex){};          
        txtBI.setText(a.getBilhete_identidade());
        txtMorada.setText(a.getMorada());
        String cod_postal1 = "";
        String cod_postal2 = "";        
        try
        {
            cod_postal1 = a.getCod_postal().substring(0, 4);            
        }
        catch(Exception ex){}
        try
        {
            cod_postal2 = a.getCod_postal().substring(5, 8);        
        }
        catch(Exception ex){}        


        txtCodPostal1.setText(cod_postal1);
        txtCodPostal2.setText(cod_postal2);
        txtLocalidade.setText(a.getLocalidade());
        txtContactoTelefonico.setText(a.getContacto_telefonico());
        try
        {
            java.util.Date ddate = new java.util.Date(a.getData_admissao().getTime());
            stDataAdmissao.setText(utils.Utils.dateToYYYYMMDD(ddate));            
        }  
        catch(Exception ex){};                  
        
        stFuncao.setText(a.getFuncao());
        rbTurnoManha.setSelected(null);
        rbTurnoTarde.setSelected(null);        
        rbTurnoNoite.setSelected(null);        
        if(a.getTurno().matches("m"))
        {
            rbTurnoManha.setSelected(new Boolean(true));
        }
        else if(a.getTurno().matches("t"))
        {
            rbTurnoTarde.setSelected(new Boolean(true));
        }
        else if(a.getTurno().matches("n"))
        {
            rbTurnoNoite.setSelected(new Boolean(true));
        }   
        
        txtNomeSuperior.setText(a.getNome_superior_hierarquico());
        txtEmailSuperior.setText(a.getEmail_superior_hierarquico());
        
    }
    
    private void fillAcidentadoView(Acidentado a)
    {
        stNomeAcidentado.setText(a.getNome());
        stEstabelecimentoOrigem1.setText(a.getEstabelecimento_origem());
        //stDataNascimento.setText(a.getData_nascimento());
        try
        {
            java.util.Date ddate = new java.util.Date(a.getData_nascimento().getTime());
            stDataNascimento.setText(utils.Utils.dateToYYYYMMDD(ddate));            
        }
        catch(Exception ex){};                                
        stBI.setText(a.getBilhete_identidade());
        stMorada.setText(a.getMorada());
        String cod_postal1 = "";
        String cod_postal2 = "";        
        try
        {
            cod_postal1 = a.getCod_postal().substring(0, 4);            
        }
        catch(Exception ex)
        {
            cod_postal1 = "";
        }
        try
        {
            cod_postal2 = a.getCod_postal().substring(5, 8);        
        }
        catch(Exception ex)
        {
            cod_postal2 = "";        
        }        

        //String cod_postal1 = a.getCod_postal().substring(0, 4);
        //String cod_postal2 = a.getCod_postal().substring(5, 8); 
        if(a.getLocalidade() == null)
        {
            a.setLocalidade("");
        }
        String cod_postal = cod_postal1 + "-" + cod_postal2 + "  " + a.getLocalidade();
        stCodPostal.setText(cod_postal);
        stContactoTelefonico.setText(a.getContacto_telefonico());
        //stDataAdmissao1.setText(a.getData_admissao());
        try
        {
            java.util.Date ddate = new java.util.Date(a.getData_admissao().getTime());
            stDataAdmissao1.setText(utils.Utils.dateToYYYYMMDD(ddate));            
        }
        catch(Exception ex){};                                        
        stFuncao1.setText(a.getFuncao());
        String turno_str =  "";
        if(a.getTurno() != null)
        {
            if(a.getTurno().matches("m"))
            {
                turno_str = "manh&atilde;";
            }
            else if(a.getTurno().matches("t"))
            {
                turno_str += "tarde ";
            }        
            else if(a.getTurno().matches("n"))
            {
                turno_str += "noite";
            }                            
        }

        stTurno.setText(turno_str);
        stNomeSuperior.setText(a.getNome_superior_hierarquico());
        stEmailSuperior.setText(a.getEmail_superior_hierarquico());        
    }    
    
    private void fillDadosAcidenteSeg(AnaliseAcidente a)
    {
        //stDataAcidente.setText(a.getData_acidente());
//        try
//        {
//            java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime());
//            stDataAcidente.setText(utils.Utils.dateToYYYYMMDD(ddate));            
//        }
//        catch(Exception ex){}; 
        if(a.getAveriguador() == null)
        {
            txtAveriguador.setText(getSessionBean1().getCurrentUser().getNome());
        }
        else
        {
            txtAveriguador.setText(a.getAveriguador());
        }
        
        if(a.getData_acidente() != null)
        {
            java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime());
            calDataOcorrencia.setValue(ddate);
        } 
        
        Calendar cal = Calendar.getInstance(); 

        // set the calendar to have your time
        try
        {
            cal.setTimeInMillis(a.getHora_acidente().getTime());

            int hour = cal.get(Calendar.HOUR_OF_DAY);
            int minutes = cal.get(Calendar.MINUTE);        
            drpHours.setSelected(new Integer(hour));
            drpMinutes.setSelected(new Integer(minutes));                    
        }
        catch(Exception ex)
        {
            //ex.printStackTrace();
        }

        if(a.getHoras_turno() != null)
        {
            txtHorasTurno.setText(a.getHoras_turno().toString());            
        }

        ////txtSeccao.setText(a.getSeccao());
        
        AnalisesDataProvider adp = new AnalisesDataProvider();
        drpDepartamento.setSelected(a.getDepartamento_id());
       try
       {
            if(a.getDepartamento_id().intValue() == 0)
            {
                getSessionBean1().setSeccaoOptions(adp.getSeccoesList(null));               
                drpSeccao.setSelected(new Integer(0));            
            }
            else
            {
                getSessionBean1().setSeccaoOptions(adp.getSeccoesList(a.getDepartamento_id()));               
                drpSeccao.setSelected(a.getSeccao_id());            
            }
       }
       catch(Exception ex)
       {
           ex.printStackTrace();
       }            
        
        txtLocal.setText(a.getLocal_trabalho());
        txtTarefa.setText(a.getTarefa());
        txtSubstancias.setText(a.getSubstancias());
//        txtSuperior.setText(a.getSuperior_hierarquico());
        txtCondicoes.setText(a.getCondicoes());
        txtTestemunhas.setText(a.getTestemunhas());
//        txtCausas.setText(a.getCausas());

        drpCausas.setSelected(a.getCausas());
        txtDescricao.setText(a.getDescricao());
        txtConclusoes.setText(a.getConclusoes());
        txtAccoes.setText(a.getAccoes());
        
        if(a.getAveriguacao_posterior().matches("y"))
        {
            chkAveriguacaoPosterior.setSelected(new Boolean(true));
        }
        
        txtAveriguacaoObs.setText(a.getAveriguacao_obs());
        
        //fill images
        if(gridImages.getChildren().size() > 0)
        {
            gridImages.getChildren().clear();
        }        
        String folderName = getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(0,2) + getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(3);        
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
        
        File apacheAnaliseFolder = new File(theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName);
        if(apacheAnaliseFolder.exists())
        {
            Global global = new Global();
            global.deleteFolderFiles(apacheAnaliseFolder);
        }
        else
        {
            apacheAnaliseFolder.mkdir();            
        }
        
        
//         String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName);                
         String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName;                        
         try
         {
            File f = new File(imageFileFolder);
            
            if(f.exists())
            {
                File images[] = f.listFiles();
                Arrays.sort(images);
                for(int i=0;i<images.length;i++)
                {
                    if(images[i].isFile())       
                    {
                        String imageName = images[i].getName();
                        ImageComponent newImg = new ImageComponent();
                        newImg.setId("img_comp" + imageName);
                        File apacheImage = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName + "/" + imageName);
                        Global global = new Global();
                        global.copyImage(images[i], apacheImage);
                        
                        newImg.setUrl(Global.RESOURCES_IMAGE_FOLDER  + "/analises/" + folderName + "/" + imageName);
                        newImg.setRendered(true);
                        gridImages.getChildren().add(newImg);
                        
                        Hyperlink ln = new Hyperlink();
                        ln.setId("img" + imageName); 
                        ln.setText("Apagar");
                        //ln.setValue(imageName);
                        Class args[] = { javax.faces.event.ActionEvent.class }; 
                        ApplicationFactory factory = (ApplicationFactory)

                        FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
                        //mb = factory.getApplication().createMethodBinding( "#{EditarQuestionario.lnkGrupo_onClick}", args);                        
                        MethodBinding mbAction = (MethodBinding) factory.getApplication().createMethodBinding("#{AnaliseAcidenteTrabalho.lnkDelImageReal_actionListener}", args);
                        ln.setActionListener(mbAction); 
                        gridImages.getChildren().add(ln);                                                
                    }
                }                
            }
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }        
    }
    
    private void fillDadosAcidenteSegView(AnaliseAcidente a)
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        
        stAveriguador.setText(a.getAveriguador());        
        if(a.getData_acidente() == null)
        {
            lblDataAcidente.setRendered(false);
            stDataAcidente1.setRendered(false);
        }
        else
        {
            try
            {
                java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime());
                stDataAcidente1.setText(utils.Utils.dateToYYYYMMDD(ddate));            
            }
            catch(Exception ex){};                            
        }
        
        if(a.getHora_acidente() == null)
        {
            lblHoraAcidente.setRendered(false);
            stHoraAcidente1.setRendered(false);
        }
        else
        {
            Calendar cal = Calendar.getInstance(); 

            // set the calendar to have your time
            cal.setTimeInMillis(a.getHora_acidente().getTime());

            int hour = cal.get(Calendar.HOUR_OF_DAY);
            int minutes = cal.get(Calendar.MINUTE); 
            try
            {
                stHoraAcidente1.setText(utils.Utils.timeToHHMM(hour + ":" + minutes));                    
            }
            catch(Exception ex){}                    
        }

        boolean booTurnoSeccaoLocal = false;
        if(a.getHoras_turno() == null)
        {
            lblHorasTurno.setRendered(false);
            txtHorasTurno2.setRendered(false);
        }
        else if(a.getHoras_turno().intValue() == 0)
        {
            lblHorasTurno.setRendered(false);
            txtHorasTurno2.setRendered(false);            
        }
        else
        {
            txtHorasTurno2.setText(a.getHoras_turno().toString()); 
            booTurnoSeccaoLocal = true;
        }        

//        if(a.getSeccao() == null)
//        {
//            lblSeccao.setRendered(false);
//            txtSeccao1.setRendered(false);
//        }
//        else if(a.getSeccao().trim().length() == 0)
//        {
//            lblSeccao.setRendered(false);
//            txtSeccao1.setRendered(false);            
//        }
//        else
//        {
//            txtSeccao1.setText(a.getSeccao());   
//            booTurnoSeccaoLocal = true;            
//        }
        
        try
        {
            Seccao s = adp.getSeccao(a.getSeccao_id());
            txtSeccao1.setText(s.getDescricao());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            lblSeccao.setRendered(false);
            txtSeccao1.setRendered(false);                        
        }
        

        if(a.getLocal_trabalho() == null)
        {
            lblLocal.setRendered(false);
            txtLocal1.setRendered(false);
        }
        else if(a.getLocal_trabalho().trim().length() == 0)
        {
            lblLocal.setRendered(false);
            txtLocal1.setRendered(false);
        }
        else
        {
            txtLocal1.setText(a.getLocal_trabalho());    
            booTurnoSeccaoLocal = true;            
        }
        
        if(! booTurnoSeccaoLocal)
        {
            gridTurnoSeccaoLocal.setRendered(false);
        }
        
        
        if(a.getTarefa() == null)
        {
            gridTarefa.setRendered(false);
            lblTarefa.setRendered(false);
            txtTarefa1.setRendered(false);
        }
        else if(a.getTarefa().trim().length() == 0)
        {
            gridTarefa.setRendered(false);            
            lblTarefa.setRendered(false);
            txtTarefa1.setRendered(false);            
        }
        else
        {
            txtTarefa1.setText(a.getTarefa());            
        }


        if(a.getSubstancias() == null)
        {
            gridSubstancias.setRendered(false);            
            lblSubstancias.setRendered(false);
            txtSubstancias1.setRendered(false);
        }
        else if(a.getSubstancias().trim().length() == 0)
        {
            gridSubstancias.setRendered(false);                        
            lblSubstancias.setRendered(false);
            txtSubstancias1.setRendered(false);            
        }
        else
        {
            txtSubstancias1.setText(a.getSubstancias());            
        }
        
//        if(a.getSuperior_hierarquico() == null)
//        {
//            gridSuperior.setRendered(false);                        
//            lblSuperior.setRendered(false);
//            txtSuperior1.setRendered(false);
//        }
//        else if(a.getSuperior_hierarquico().trim().length() == 0)
//        {
//            gridSuperior.setRendered(false);                                    
//            lblSuperior.setRendered(false);
//            txtSuperior1.setRendered(false);
//        }
//        else
//        {
//            txtSuperior1.setText(a.getSuperior_hierarquico());            
//        }

        if(a.getCondicoes() == null)
        {
            gridCondicoes.setRendered(false);                                    
            lblCondicoes.setRendered(false);
            txtCondicoes1.setRendered(false);
        }
        else if(a.getCondicoes().trim().length() == 0)
        {
            gridCondicoes.setRendered(false);                                                
            lblCondicoes.setRendered(false);
            txtCondicoes1.setRendered(false);
        }
        else
        {
            txtCondicoes1.setText(a.getCondicoes());            
        }

        if(a.getTestemunhas() == null)
        {
            gridTestemunhas.setRendered(false);                                                
            lblTestemunhas.setRendered(false);
            txtTestemunhas1.setRendered(false);
        }
        else if(a.getTestemunhas().trim().length() == 0)
        {
            gridTestemunhas.setRendered(false);                                                            
            lblTestemunhas.setRendered(false);
            txtTestemunhas1.setRendered(false);            
        }
        else
        {
            txtTestemunhas1.setText(a.getTestemunhas());            
        }

//        txtCausas1.setText(a.getCausas());
        try
        {
            Causa c = adp.getCausa(a.getCausas());
            txtCausas1.setText(c.getCausa());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            gridCausas.setRendered(false);            
        }
        
        if(a.getDescricao() == null)
        {
            gridDescricao.setRendered(false);                                                            
            lblDescricao.setRendered(false);
            txtDescricao1.setRendered(false);
        }
        else if(a.getDescricao().trim().length() == 0)
        {
            gridDescricao.setRendered(false);                                                                        
            lblDescricao.setRendered(false);
            txtDescricao1.setRendered(false);            
        }
        else
        {
            txtDescricao1.setText(a.getDescricao());            
        }
        
        if(a.getConclusoes() == null)
        {
            gridConclusoes.setRendered(false);                                                                        
            lblConclusoes.setRendered(false);
            txtConclusoes1.setRendered(false);
        }
        else if(a.getConclusoes().trim().length() == 0)
        {
            gridConclusoes.setRendered(false);                                                                                    
            lblConclusoes.setRendered(false);
            txtConclusoes1.setRendered(false);            
        }
        else
        {
            txtConclusoes1.setText(a.getConclusoes());
        }

        if(a.getAccoes() == null)
        {
            gridAccoes.setRendered(false);                                                                                    
            lblAccoes.setRendered(false);
            txtAccoes1.setRendered(false);
        }
        else if(a.getAccoes().trim().length() == 0)
        {
            gridAccoes.setRendered(false);                                                                                                
            lblAccoes.setRendered(false);
            txtAccoes1.setRendered(false);
        }
        else
        {
            txtAccoes1.setText(a.getAccoes());                
        }
        
        if(a.getAveriguacao_posterior().matches("y"))
        {
            if(a.getAveriguacao_obs().trim().length() == 0) // must edit
            {
                if(getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_SEGURANCA)  // seguranca
                {
                    gridAveriguacaoPosterior.setRendered(false);                                    
                }
                else
                {
                    gridAveriguacaoPosterior.setRendered(false);                     
                    gridAveriguacaoPosterior1.setRendered(false);                     
                }
            }
            else
            {
                gridAveriguacaoPosterior1.setRendered(false);            
                txtAveriguacaoPosterior.setText("Averigua&ccedil;&atilde;o posterior: " + a.getAveriguacao_obs());
            }
        }
        else
        {
            gridAveriguacaoPosterior.setRendered(false);                     
            gridAveriguacaoPosterior1.setRendered(false);                                 
        }
        
        //fill images
        if(gridImages.getChildren().size() > 0)
        {
            gridImages.getChildren().clear();
        }        
        String folderName = a.getAnalise_nr().substring(0,2) + a.getAnalise_nr().substring(3);        
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
//         String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName);                

        File apacheAnaliseFolder = new File(theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName);
        if(apacheAnaliseFolder.exists())
        {
            Global global = new Global();
            global.deleteFolderFiles(apacheAnaliseFolder);
            System.out.println("FILES DELETED");
        }
        else
        {
            apacheAnaliseFolder.mkdir();            
        }        
        
        
         String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName;                         
         try
         {
            File f = new File(imageFileFolder);
            
            if(f.exists())
            {
                File images[] = f.listFiles();
                Arrays.sort(images);
                for(int i=0;i<images.length;i++)
                {
                    if(images[i].isFile())       
                    {
                        String imageName = images[i].getName();
                        ImageComponent newImg = new ImageComponent();
                        
                        File apacheImage = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName + "/" + imageName);
                        Global global = new Global();
                        global.copyImage(images[i], apacheImage);
                        
                        newImg.setUrl(Global.RESOURCES_IMAGE_FOLDER  + "/analises/" + folderName + "/" + imageName);                        
                        
                        
                        //newImg.setUrl("/resources/images/" + getSessionBean1().getCurrentAnalise().getId() + "/" + imageName);
                        //newImg.setUrl(Global.IMAGE_FOLDER + "/" + folderName + "/" + imageName);                        
                        newImg.setRendered(true);
                        gridImages1.getChildren().add(newImg);
                    }
                }                
            }
            else
            {
                gridFotografias.setRendered(false);                                                                                                    
                lblFotografias.setRendered(false);
                gridImages1.setRendered(false);
            }
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }                
    }    
    
    private void fillDadosAcidenteRh(AnaliseAcidente a)
    {
        if(a.getFormacao_shst().matches("y"))
        {
            rbFormacaoSHSTY.setSelected(new Boolean(true));
        }
        else if( a.getFormacao_shst().matches("n") )
        {
            rbFormacaoSHSTN.setSelected(new Boolean(true));
            txtFormacaoSHSTNWhy.setText(a.getFormacao_shst_nao_porque());
        }
        else  //t
        {
            rbFormacaoSHSTY.setSelected(null);
            rbFormacaoSHSTN.setSelected(null);                    
        }
        
        if(a.getOutros_acidentes_com_colaborador().matches("y"))
        {
            rbAcidentesColaboradorY.setSelected(new Boolean(true));
            try
            {
                txtNrAcidentesColaborador.setText(a.getNr_acidentes_com_colaborador().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
            try
            {
                txtNrRelatorioAcidentesColaborador1.setText(a.getNr_relatorio_acidente_colaborador1().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }            
            try
            {
                txtNrRelatorioAcidentesColaborador2.setText(a.getNr_relatorio_acidente_colaborador2().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }   
            try
            {
                txtNrRelatorioAcidentesColaborador3.setText(a.getNr_relatorio_acidente_colaborador3().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }   
            try
            {
                txtNrRelatorioAcidentesColaborador4.setText(a.getNr_relatorio_acidente_colaborador4().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }                        
        }
        else if(a.getOutros_acidentes_com_colaborador().matches("n"))
        {
            rbAcidentesColaboradorN.setSelected(new Boolean(true));            
        }
        else //t
        {
            rbAcidentesColaboradorY.setSelected(null);
            rbAcidentesColaboradorN.setSelected(null);                    
        }
        
        if(a.getAcidentes_outros_colaboradores().matches("y"))
        {
            rbAcidentesColaboradoresY.setSelected(new Boolean(true)); 
            try
            {
                txtNrAcidentesColaboradores.setText(a.getNr_acidentes_outros_colaboradores().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
            
            try
            {
                txtNrRelatorioAcidentesColaboradores1.setText(a.getNr_relatorio_acidente_outros_colaboradores1().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }            
            
            try
            {
                txtNrRelatorioAcidentesColaboradores2.setText(a.getNr_relatorio_acidente_outros_colaboradores2().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            } 
            
            try
            {
                txtNrRelatorioAcidentesColaboradores3.setText(a.getNr_relatorio_acidente_outros_colaboradores3().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
            
            try
            {
                txtNrRelatorioAcidentesColaboradores4.setText(a.getNr_relatorio_acidente_outros_colaboradores4().toString());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }                        
        }
        else if( a.getAcidentes_outros_colaboradores().matches("n") )
        {
            rbAcidentesColaboradoresN.setSelected(new Boolean(true));
        }
        else //t
        {
            rbAcidentesColaboradoresY.setSelected(null);
            rbAcidentesColaboradoresN.setSelected(null);                            
        }
    }  
    
    private void fillDadosAcidenteRhView(AnaliseAcidente a)    
    {
        StaticText st = new StaticText();
        st.setId("stSHST");
        st.setEscape(false);
        
        StaticText st1 = new StaticText();
        st1.setId("stColaborador");
        st1.setEscape(false);        
        
        StaticText st2 = new StaticText();
        st2.setId("stColaboradores");
        st2.setEscape(false);        
        
        if(a.getFormacao_shst().matches("y"))
        {
            st.setText("O colaborador teve forma&ccedil;&atilde;o em SHST.");
            gridSHST.getChildren().add(st);                        
        }
        else if( a.getFormacao_shst().matches("n") )
        {
            st.setText("O colaborador n&atilde;o teve forma&ccedil;&atilde;o em SHST.");            
            gridSHST.getChildren().add(st);        
            HtmlPanelGrid grd = new HtmlPanelGrid();
            grd.setId("grdMotivo");
            grd.setColumns(2);
            grd.setColumnClasses("gridColLeft5, gridColLeft95");
            StaticText s = new StaticText();
            s.setId("stMotivo");
            s.setEscape(false);
            s.setText("Motivo:&nbsp;");
            grd.getChildren().add(s);
            s = new StaticText();
            s.setId("stMotivo1");
            s.setEscape(false);
            s.setText(a.getFormacao_shst_nao_porque());            
            grd.getChildren().add(s);            
            gridSHST.getChildren().add(grd);
        }
        else
        {
            gridSHST.setRendered(false);
        }

        
        if(a.getOutros_acidentes_com_colaborador().matches("y"))
        {
            st1.setText("Verificaram-se outras ocorr&ecirc;ncias/inicid&ecirc;ncias no mesmo posto de trabalho com o colaborador acidentado.");
            gridColaborador.getChildren().add(st1);
            boolean booShow = false;
            boolean booShow1 = false;            
            boolean booShow2 = false;                        
            if(a.getNr_acidentes_com_colaborador() != null)
            {
                booShow = true;
                booShow1 = true;                
            }
            if(a.getNr_relatorio_acidente_colaborador1() != null || a.getNr_relatorio_acidente_colaborador2() != null || a.getNr_relatorio_acidente_colaborador3() != null || a.getNr_relatorio_acidente_colaborador4() != null)
            {
                booShow = true;
                booShow2 = true;                                
            }
            
            if(booShow)
            {
                HtmlPanelGrid grd = new HtmlPanelGrid();
                grd.setId("grdColaboradorS");
                grd.setColumns(2);
                grd.setColumnClasses("gridColLeft15, gridColLeft85");                
                if(booShow1)
                {
                    PanelGroup pg = new PanelGroup();
                    StaticText s = new StaticText();
                    s.setId("s100");
                    s.setEscape(false);
                    s.setText("Total: &nbsp;");
                    pg.getChildren().add(s);
                    s = new StaticText();
                    s.setId("s101");
                    s.setEscape(false);
                    s.setText(a.getNr_acidentes_com_colaborador().toString());
                    pg.getChildren().add(s);                    
                    grd.getChildren().add(pg);
                }
                if(booShow2)
                {
                    PanelGroup pg = new PanelGroup();
                    StaticText s = new StaticText();
                    s.setId("s102");
                    s.setEscape(false);
                    s.setText("Relat&oacute;rios de acidente n&#186;: &nbsp;");
                    pg.getChildren().add(s);   
                    if(a.getNr_relatorio_acidente_colaborador1() != null)
                    {
                        if(a.getNr_relatorio_acidente_colaborador1().intValue() > 0)
                        {
                            s = new StaticText();
                            s.setId("s103");
                            s.setEscape(false);
                            s.setText(a.getNr_relatorio_acidente_colaborador1());
                            pg.getChildren().add(s);                            
                        }
                    }
                    if(a.getNr_relatorio_acidente_colaborador2() != null)
                    {
                        if(a.getNr_relatorio_acidente_colaborador2().intValue() > 0)
                        {
                            s = new StaticText();
                            s.setId("s104");
                            s.setEscape(false);
                            s.setText("&nbsp;&nbsp;" + a.getNr_relatorio_acidente_colaborador2());
                            pg.getChildren().add(s);                            
                        }                        

                    }                    
                    if(a.getNr_relatorio_acidente_colaborador3() != null)
                    {
                        if(a.getNr_relatorio_acidente_colaborador3().intValue() > 0)
                        {
                            s = new StaticText();
                            s.setId("s105");
                            s.setEscape(false);
                            s.setText("&nbsp;&nbsp;" + a.getNr_relatorio_acidente_colaborador3());
                            pg.getChildren().add(s);                            
                        }
                    }                                       
                    if(a.getNr_relatorio_acidente_colaborador4() != null)
                    {
                        if(a.getNr_relatorio_acidente_colaborador4().intValue() > 0)
                        {                        
                            s = new StaticText();
                            s.setId("s106");
                            s.setEscape(false);
                            s.setText("&nbsp;&nbsp;" + a.getNr_relatorio_acidente_colaborador4());
                            pg.getChildren().add(s);                            
                        }
                    }                                                            
                    grd.getChildren().add(pg);                    
                }
                gridColaborador.getChildren().add(grd);                
            }
            
        }
        else if( a.getOutros_acidentes_com_colaborador().matches("n") )
        {
            st1.setText("N&atilde;o se verificaram outras ocorr&ecirc;ncias/incid&ecirc;ncias no mesmo posto de trabalho com o colaborador acidentado.");
            gridColaborador.getChildren().add(st1);    
        }
        else //t
        {
            gridColaborador.setRendered(false);
        }
        
        if(a.getAcidentes_outros_colaboradores().matches("y"))
        {
            st2.setText("Verificaram-se ocorr&ecirc;ncias/incidentes semelhantes com outros colaboradores.");
            gridColaboradores.getChildren().add(st2);
            boolean booShow = false;
            boolean booShow1 = false;            
            boolean booShow2 = false;                        
            if(a.getNr_acidentes_outros_colaboradores() != null)
            {
                booShow = true;
                booShow1 = true;                
            }
            if(a.getNr_relatorio_acidente_outros_colaboradores1() != null || a.getNr_relatorio_acidente_outros_colaboradores2() != null || a.getNr_relatorio_acidente_outros_colaboradores3() != null || a.getNr_relatorio_acidente_outros_colaboradores4() != null)
            {
                booShow = true;
                booShow2 = true;                                
            }
            
            if(booShow)
            {
                HtmlPanelGrid grd = new HtmlPanelGrid();
                grd.setId("grdColaboradoresS");
                grd.setColumns(2);
                grd.setColumnClasses("gridColLeft15, gridColLeft85");                
                if(booShow1)
                {
                    PanelGroup pg = new PanelGroup();
                    StaticText s = new StaticText();
                    s.setId("s200");
                    s.setEscape(false);
                    s.setText("Total: &nbsp;");
                    pg.getChildren().add(s);
                    s = new StaticText();
                    s.setId("s201");
                    s.setEscape(false);
                    s.setText(a.getNr_acidentes_outros_colaboradores());
                    pg.getChildren().add(s);                    
                    grd.getChildren().add(pg);
                }
                if(booShow2)
                {
                    PanelGroup pg = new PanelGroup();
                    StaticText s = new StaticText();
                    s.setId("s202");
                    s.setEscape(false);
                    s.setText("Relat&oacute;rios de acidente n&#186;: &nbsp;");
                    pg.getChildren().add(s);   
                    if(a.getNr_relatorio_acidente_outros_colaboradores1() != null)
                    {
                        if(a.getNr_relatorio_acidente_outros_colaboradores1().intValue() > 0)
                        {
                            s = new StaticText();
                            s.setId("s203");
                            s.setEscape(false);
                            s.setText(a.getNr_relatorio_acidente_outros_colaboradores1());
                            pg.getChildren().add(s);                            
                        }
                    }
                    if(a.getNr_relatorio_acidente_outros_colaboradores2() != null)
                    {
                        if(a.getNr_relatorio_acidente_outros_colaboradores2().intValue() > 0)
                        {                        
                            s = new StaticText();
                            s.setId("s204");
                            s.setEscape(false);
                            s.setText("&nbsp;&nbsp;" + a.getNr_relatorio_acidente_outros_colaboradores2());
                            pg.getChildren().add(s);                            
                        }
                    }                    
                    if(a.getNr_relatorio_acidente_outros_colaboradores3() != null)
                    {
                        if(a.getNr_relatorio_acidente_outros_colaboradores3().intValue() > 0)
                        {                                                
                            s = new StaticText();
                            s.setId("s205");
                            s.setEscape(false);
                            s.setText("&nbsp;&nbsp;" + a.getNr_relatorio_acidente_outros_colaboradores3());
                            pg.getChildren().add(s);                            
                        }
                    }                                       
                    if(a.getNr_relatorio_acidente_outros_colaboradores4() != null)
                    {
                        if(a.getNr_relatorio_acidente_outros_colaboradores4().intValue() > 0)
                        {                                                  
                            s = new StaticText();
                            s.setId("s206");
                            s.setEscape(false);
                            s.setText("&nbsp;&nbsp;" + a.getNr_relatorio_acidente_outros_colaboradores4());
                            pg.getChildren().add(s);                            
                        }                      
                    }                                                            
                    grd.getChildren().add(pg);                    
                }
                gridColaboradores.getChildren().add(grd);                
            }                        
        }
        else if( a.getAcidentes_outros_colaboradores().matches("n") )
        {
            st2.setText("N&atilde;o se verificaram ocorr&ecirc;ncias/incidentes com outros colaboradores.");
            gridColaboradores.getChildren().add(st2);            
        }        
        else //t
        {
            gridColaboradores.setRendered(false);
        }
    }
    
    private void fillRecomendacoesHs(AnaliseAcidente a)
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        try
        {
            ArrayList list = adp.getRecomendacoesByAnalise(a.getId());
            ListIterator iter = list.listIterator();
            int seq = 1;
            while(iter.hasNext())
            {
                Recomendacao r = (Recomendacao) iter.next();
                if(seq==1)
                {
                    txtRecomendacao1.setText(r.getRecomendacao());
                }
                else
                {
                    
                    //int seq = gridRecomendacoes.getChildren().size();
                    //seq++;        
                    HtmlPanelGrid grd = new HtmlPanelGrid();
                    grd.setId("grd" + seq);
                    grd.setColumns(3);
                    grd.setColumnClasses("gridColLeft5, gridColLeft90,gridColLeft5");
                    grd.setStyle("width: 100%");        

                    StaticText st = new StaticText();
                    st.setId("st" + seq);
                    st.setText(seq + " .");
                    st.setStyle("width: 24px");        
                    grd.getChildren().add(st);

                    TextArea ta = new TextArea();
                    ta.setId("ta" + seq);        
                    ta.setStyle("height: 24px; width: 98%");
                    ta.setText(r.getRecomendacao());
                    grd.getChildren().add(ta);  

                    ImageHyperlink ln = new ImageHyperlink();
                    ln.setId("ln" + seq);        
                    ln.setWidth(9);
                    ln.setHeight(9);
                    ln.setImageURL("/resources/plus_more.gif");
                    MethodBinding mbAction = this.getApplication().createMethodBinding("#{AnaliseAcidenteTrabalho.lnkMoreRec1_action}", null);
                    ln.setAction(mbAction); 

                    grd.getChildren().add(ln);          

                    gridRecomendacoes.getChildren().add(grd);                    
                    
                }
                seq++;
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }    
    
    private void fillRecomendacoesViewHs(AnaliseAcidente a)
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        try
        {
            ArrayList list = adp.getRecomendacoesByAnalise(a.getId());
            ListIterator iter = list.listIterator();
            int seq = 1;
            while(iter.hasNext())
            {
                Recomendacao r = (Recomendacao) iter.next();
                HtmlPanelGrid grd = new HtmlPanelGrid();
                grd.setId("grdRecomendacaoView" + seq);
                grd.setColumns(2);
                grd.setColumnClasses("gridColLeft5, gridColLeft95");
                grd.setStyle("width: 100%");                  
                
                StaticText st = new StaticText();
                st.setId("stNrRecomendacaoView" + seq);
                st.setText(seq + " .");
                st.setStyle("width: 24px");        
                grd.getChildren().add(st);
                
                st = new StaticText();
                st.setId("stRecomendacaoView" + seq);
                st.setText(r.getRecomendacao());
                //st.setStyle("width: 24px");        
                grd.getChildren().add(st);  
                
                gridRecomendacoesView.getChildren().add(grd);
                seq++;
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
    
    private void fillMedidasRh(AnaliseAcidente a)
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        try
        {
            ArrayList list = adp.getMedidasByAnalise(a.getId());
            ListIterator iter = list.listIterator();
            int seq = 1;
            while(iter.hasNext())
            {
                Medida m = (Medida) iter.next();
                if(seq==1)
                {
                    txtMedida1.setText(m.getMedida());
                }
                else
                {
                    HtmlPanelGrid grd = new HtmlPanelGrid();
                    grd.setId("grdMedida" + seq);
                    grd.setColumns(3);
                    grd.setColumnClasses("gridColLeft5, gridColLeft90,gridColLeft5");
                    grd.setStyle("width: 100%");        

                    StaticText st = new StaticText();
                    st.setId("stNrMedida" + seq);
                    st.setText(seq + " .");
                    st.setStyle("width: 24px");        
                    grd.getChildren().add(st);

                    TextArea ta = new TextArea();
                    ta.setId("taMedida" + seq);        
                    ta.setStyle("height: 24px; width: 98%");
                    ta.setText(m.getMedida());
                    grd.getChildren().add(ta);  

                    ImageHyperlink ln = new ImageHyperlink();
                    ln.setId("lnMedidaMore" + seq);        
                    ln.setWidth(9);
                    ln.setHeight(9);
                    ln.setImageURL("/resources/plus_more.gif");
                    MethodBinding mbAction = this.getApplication().createMethodBinding("#{AnaliseAcidenteTrabalho.lnkMoreMed_action}", null);
                    ln.setAction(mbAction); 

                    grd.getChildren().add(ln);          

                    gridMedidas.getChildren().add(grd);                    
                }
                seq++;
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }        
    }        
    
    private void fillMedidasViewRh(AnaliseAcidente a)
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        try
        {
            ArrayList list = adp.getMedidasByAnalise(a.getId());
            ListIterator iter = list.listIterator();
            int seq = 1;
            while(iter.hasNext())
            {
                Medida m = (Medida) iter.next();
                HtmlPanelGrid grd = new HtmlPanelGrid();
                grd.setId("grdMedidaView" + seq);
                grd.setColumns(2);
                grd.setColumnClasses("gridColLeft5, gridColLeft95");
                grd.setStyle("width: 100%");                  
                
                StaticText st = new StaticText();
                st.setId("stNrMedidaView" + seq);
                st.setText(seq + " .");
                st.setStyle("width: 24px");        
                grd.getChildren().add(st);
                
                st = new StaticText();
                st.setId("stMedidaView" + seq);
                st.setText(m.getMedida());
                //st.setStyle("width: 24px");        
                grd.getChildren().add(st);  
                
                gridMedidasView.getChildren().add(grd);
                seq++;
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }        
    }
    
    private void fillMedico(AnaliseAcidente a)
    {

        if(a.getLesao_cabeca().matches("y"))
        {
            chkCabeca.setSelected( new Boolean(true) );                    
        }
        
        if(a.getLesao_pescoco().matches("y"))
        {
            chkPescoco.setSelected(new Boolean(true));
        }
        
        if(a.getLesao_tronco().matches("y"))
        {
            chkTronco.setSelected(new Boolean(true));
        }
        
        if(a.getLesao_membro_sup_dir().matches("y"))
        {
            chkMembroSupDir.setSelected(new Boolean(true));
            //lblEspecif1.setRendered(true);
            //txtEspecif1.setRendered(true);
            lblEspecif1.setVisible(true);            
            txtEspecif1.setVisible(true);
            
            txtEspecif1.setText(a.getEspecif1());
        }
        else
        {
            //lblEspecif1.setRendered(false);
            //txtEspecif1.setRendered(false);  
            lblEspecif1.setVisible(false);
            txtEspecif1.setVisible(false);            
            
        }
        
        if(a.getLesao_membro_sup_esq().matches("y"))
        {
            chkMembroSupEsq.setSelected(new Boolean(true));
//            lblEspecif2.setRendered(true);
//            txtEspecif2.setRendered(true);            
            lblEspecif2.setVisible(true);
            txtEspecif2.setVisible(true);                        
            txtEspecif2.setText(a.getEspecif2());
        }
        else
        {
            lblEspecif2.setVisible(false);
            txtEspecif2.setVisible(false);            
        }        
        
        if(a.getLesao_membro_inf_dir().matches("y"))
        {
            chkMembroInfDir.setSelected(new Boolean(true));
            lblEspecif3.setVisible(true);
            txtEspecif3.setVisible(true);            
            txtEspecif3.setText(a.getEspecif3());
        }        
        else
        {
            lblEspecif3.setVisible(false);
            txtEspecif3.setVisible(false);            
        }        
        
        if(a.getLesao_membro_inf_esq().matches("y"))
        {
            chkMembroInfEsq.setSelected(new Boolean(true));
            lblEspecif4.setVisible(true);
            txtEspecif4.setVisible(true);            
            txtEspecif4.setText(a.getEspecif4());
        }
        else
        {
            lblEspecif4.setVisible(false);
            txtEspecif4.setVisible(false);            
        }        
        
        txtTipoLesao.setText(a.getTipo_lesao());
        if(a.getTipo_incapacidade().matches("n"))
        {
            rbIncapacidadeNone.setSelected(new Boolean(true));
        }        
        else if(a.getTipo_incapacidade().matches("t"))
        {
            rbIncapacidadeTemp.setSelected(new Boolean(true));
        }
        else if(a.getTipo_incapacidade().matches("p"))
        {
            rbIncapacidadePerm.setSelected(new Boolean(true));
        }
        else
        {
            rbIncapacidadeNone.setSelected(null);
            rbIncapacidadeTemp.setSelected(null);
            rbIncapacidadePerm.setSelected(null);
        }
        
        if(a.getCoef_incapacidade() == null)
        {
            txtCoefIncapacidade.setText("");
        }
        else
        {
            txtCoefIncapacidade.setText(a.getCoef_incapacidade());            
        }

        
        if(a.getData_aval_incapacidade() != null)
        {
            java.util.Date ddate = new java.util.Date(a.getData_aval_incapacidade().getTime());
            calAvaliacaoIncap.setValue(ddate);
        }
        
        if(a.getData_rev_incapacidade() != null)
        {
            java.util.Date ddate = new java.util.Date(a.getData_rev_incapacidade().getTime());   
            calRevisaoIncap.setValue(ddate);
        }
        
        if(a.getPeriodo_incapacidade_de() != null)
        {
            java.util.Date ddate = new java.util.Date(a.getPeriodo_incapacidade_de().getTime());   
            calPeridoIncapDe.setValue(ddate);        
        }

        if(a.getPeriodo_incapacidade_a() != null)
        {
            java.util.Date ddate = new java.util.Date(a.getPeriodo_incapacidade_a().getTime());   
            calPeriodoIncapA.setValue(ddate);                            
        }

        if(a.getImg_flexao().matches("y"))
        {
            chkImgFlexao.setSelected(new Boolean(true));
        }
        
        if(a.getImg_rot1().matches("y"))
        {
            chkImgRot1.setSelected(new Boolean(true));
        }        
        
        if(a.getImg_rot2().matches("y"))
        {
            chkImgRot2.setSelected(new Boolean(true));
        }                
        
        if(a.getImg_ext1().matches("y"))
        {
            chkImgExt1.setSelected(new Boolean(true));
        }
        
        if(a.getImg_ext2().matches("y"))
        {
            chkImgExt2.setSelected(new Boolean(true));
        }        
        
        if(a.getImg_cab1().matches("y"))
        {
            chkImgCab1.setSelected(new Boolean(true));
        }                
        
        if(a.getImg_cab2().matches("y"))
        {
            chkImgCab2.setSelected(new Boolean(true));
        }        
        
        if(a.getImg_cab3().matches("y"))
        {
            chkImgCab3.setSelected(new Boolean(true));
        }             
        
        if(a.getImg_cab4().matches("y"))
        {
            chkImgCab4.setSelected(new Boolean(true));
        }                
        
        if(a.getImg_ma1().matches("y"))
        {
            chkImgMa1.setSelected(new Boolean(true));
        }                        
        
        if(a.getImg_ma2().matches("y"))
        {
            chkImgMa2.setSelected(new Boolean(true));
        }                
        
        if(a.getImg_ma3().matches("y"))
        {
            chkImgMa3.setSelected(new Boolean(true));
        }            
        
        if(a.getImg_ma4().matches("y"))
        {
            chkImgMa4.setSelected(new Boolean(true));
        }                        
        
        if(a.getImg_ma5().matches("y"))
        {
            chkImgMa5.setSelected(new Boolean(true));
        }            
        
        if(a.getImg_ma6().matches("y"))
        {
            chkImgMa6.setSelected(new Boolean(true));
        }            
        
        if(a.getImg_ma7().matches("y"))
        {
            chkImgMa7.setSelected(new Boolean(true));
        }                        
        
        if(a.getImg_ma8().matches("y"))
        {
            chkImgMa8.setSelected(new Boolean(true));
        }            
        
        if(a.getImg_ma9().matches("y"))
        {
            chkImgMa9.setSelected(new Boolean(true));
        }                        
        
        if(a.getImg_ma10().matches("y"))
        {
            chkImgMa10.setSelected(new Boolean(true));
        } 
        
        if(a.getRestricao_carga() != null)
        {
            if(a.getRestricao_carga().intValue() > 0)
            {
                chkRestricaoCargas.setSelected(new Boolean(true));
                rbKgs2.setRendered(true);
                rbKgs5.setRendered(true);            
                rbKgs10.setRendered(true);            
                rbKgs15.setRendered(true);            
                rbKgsOutro.setRendered(true);            
                txtKgs.setRendered(true);
                stKgs2.setRendered(true);
                stKgs5.setRendered(true);            
                stKgs10.setRendered(true);            
                stKgs15.setRendered(true);            
                stKgsOutro.setRendered(true);            
                stKg.setRendered(true);                            
                int carga = a.getRestricao_carga().intValue();
                switch(carga)
                {
                    case 2:
                        rbKgs2.setSelected(new Boolean(true));
                        break;
                    case 5:
                        rbKgs5.setSelected(new Boolean(true));                    
                        break;
                    case 10:
                        rbKgs10.setSelected(new Boolean(true));                    
                        break;
                    case 15:
                        rbKgs15.setSelected(new Boolean(true));                    
                        break;
                    default:
                        rbKgsOutro.setSelected(new Boolean(true));
                        txtKgs.setText(a.getRestricao_carga().toString());
                        break;
                }                
            }
            else
            {
                chkRestricaoCargas.setSelected(new Boolean(false));                
                rbKgs2.setRendered(false);
                rbKgs5.setRendered(false);            
                rbKgs10.setRendered(false);            
                rbKgs15.setRendered(false);            
                rbKgsOutro.setRendered(false);            
                txtKgs.setRendered(false);
                stKgs2.setRendered(false);
                stKgs5.setRendered(false);            
                stKgs10.setRendered(false);            
                stKgs15.setRendered(false);            
                stKgsOutro.setRendered(false);            
                stKg.setRendered(false);                        
            }
        }
        else
        {
            chkRestricaoCargas.setSelected(new Boolean(false));            
            rbKgs2.setRendered(false);
            rbKgs5.setRendered(false);            
            rbKgs10.setRendered(false);            
            rbKgs15.setRendered(false);            
            rbKgsOutro.setRendered(false);            
            txtKgs.setRendered(false);
            stKgs2.setRendered(false);
            stKgs5.setRendered(false);            
            stKgs10.setRendered(false);            
            stKgs15.setRendered(false);            
            stKgsOutro.setRendered(false);            
            stKg.setRendered(false);            
        }
        
        if(a.getRestricao_motricidade().matches("y"))
        {
            chkRestricaoMotricidade.setSelected(new Boolean(true));
        }
        
        if(a.getRestricao_conducao().matches("y"))
        {
            chkRestricaoConducao.setSelected(new Boolean(true));
        }
        
        if(a.getRestricao_vibracoes().matches("y"))
        {
            chkRestricaoVibracoes.setSelected(new Boolean(true));
        }
        
        if(a.getRestricao_outras() != null)
        {
            if(a.getRestricao_outras().trim().length() > 0)
            {
                chkRestricaoOutras.setSelected(new Boolean(true));
                txtRestricaoOutras.setText(a.getRestricao_outras());
            }
        }
        
        txtObservacoes.setText(a.getMed_observ());
        
    }
    
    private void fillMedicoView(AnaliseAcidente a)
    {
        PanelGroup pg = null;
        StaticText st = null;
        HtmlPanelGrid grd = null;
        ImageComponent img = null;         
        //LESAO :
        
        if(a.getLesao_cabeca().matches("y"))
        {
            st = new StaticText();
            st.setId("stLesaoCabeca");
            st.setEscape(false);
            st.setText("Cabe&ccedil;a");
            gridLesao.getChildren().add(st);
        }
        
        if(a.getLesao_pescoco().matches("y"))
        {
            st = new StaticText();
            st.setId("stLesaoPescoco");
            st.setEscape(false);
            st.setText("Pesco&ccedil;o");
            gridLesao.getChildren().add(st);            
        }
        
        if(a.getLesao_tronco().matches("y"))
        {
            st = new StaticText();
            st.setId("stLesaoTronco");
            st.setEscape(false);
            st.setText("Tronco");
            gridLesao.getChildren().add(st);            
        }        
        
        grd = new HtmlPanelGrid();
        grd.setId("gridLesaoMembros");
        grd.setColumns(2);
        grd.setColumnClasses("gridColLeft");
        if(a.getLesao_membro_sup_dir().matches("y"))
        {
            st = new StaticText();
            st.setId("stLesaoMembroSupDir");
            st.setEscape(false);
            st.setText("Membro Superior Direito");
            grd.getChildren().add(st);
            if(a.getEspecif1() != null)
            {
                if(a.getEspecif1().trim().length() > 0)
                {
                    st = new StaticText();
                    st.setId("stEspecif1");
                    st.setEscape(false);
                    st.setText(" - " + a.getEspecif1());
                    grd.getChildren().add(st);                                                
                }
            }

        }
        
        if(a.getLesao_membro_sup_esq().matches("y"))
        {
            st = new StaticText();
            st.setId("stLesaoMembroSupEsq");
            st.setEscape(false);
            st.setText("Membro Superior Esquerdo");
            grd.getChildren().add(st);
            if(a.getEspecif2() != null)            
            {
                if(a.getEspecif2().trim().length() > 0)
                {
                    st = new StaticText();
                    st.setId("stEspecif2");
                    st.setEscape(false);
                    st.setText(" - " + a.getEspecif2());
                    grd.getChildren().add(st);                                        
                }                
            }

        }        
        
        if(a.getLesao_membro_inf_dir().matches("y"))
        {
            st = new StaticText();
            st.setId("stLesaoMembroInfDir");
            st.setEscape(false);
            st.setText("Membro Inferior Direito");
            grd.getChildren().add(st);
            if(a.getEspecif3() != null)            
            {
                if(a.getEspecif3().trim().length() > 0)
                {
                    st = new StaticText();
                    st.setId("stEspecif3");
                    st.setEscape(false);
                    st.setText(a.getEspecif3());
                    grd.getChildren().add(st);                                                            
                }
            }
        }        
        
        if(a.getLesao_membro_inf_esq().matches("y"))
        {
            st = new StaticText();
            st.setId("stLesaoMembroInfEsq");
            st.setEscape(false);
            st.setText("Membro Inferior Esquerdo");
            grd.getChildren().add(st);
            if(a.getEspecif4() != null)            
            {       
                if(a.getEspecif4().trim().length() > 0)
                {
                    st = new StaticText();
                    st.setId("stEspecif4");
                    st.setEscape(false);
                    st.setText(a.getEspecif4());
                    grd.getChildren().add(st);                                                            
                }
            }

        }                
        if(grd.getChildren().size() > 0)
        {
            gridLesao.getChildren().add(grd);                  
        }
        
        if(a.getTipo_lesao().trim().length() > 0 )
        {
            pg = new PanelGroup();
            pg.setId("pgTipoLesao");
            st = new StaticText();
            st.setId("stTipoLesaoLbl");
            st.setEscape(false);
            st.setText("Tipo de les&atilde;o: &nbsp;&nbsp;");
            pg.getChildren().add(st);
            st = new StaticText();
            st.setId("stTipoLesao");
            st.setEscape(false);
            st.setText(a.getTipo_lesao());
            pg.getChildren().add(st);   
            gridLesao.getChildren().add(pg);
        }
        
        //INCAPACIDADE :
        pg = new PanelGroup();
        pg.setId("pgTipoIncapacidade");
        st = new StaticText();
        st.setId("stTipoIncapacidadeLbl1");
        st.setStyle("font-weight: bold");
        st.setEscape(false);
        st.setText("Tipo de incapacidade:&nbsp;&nbsp;");
        if(a.getTipo_incapacidade().matches("t"))
        {
            pg.getChildren().add(st);            
            st = new StaticText();
            st.setId("stTipoIncapacidade");
            st.setEscape(false);
            st.setText("Tempor&aacute;ria&nbsp;&nbsp;");            
            pg.getChildren().add(st);
            st = new StaticText();
            st.setId("stTipoIncapacidadeLbl2");
            st.setStyle("font-weight: bold");                        
            st.setEscape(false);
            st.setText("Coeficiente de incapacidade:&nbsp;&nbsp;");            
            pg.getChildren().add(st);            
            st = new StaticText();
            st.setId("stCoefIncapacidade");
            st.setEscape(false);
            st.setText(a.getCoef_incapacidade().toString() + "%");            
            pg.getChildren().add(st);                        
        }
        else if(a.getTipo_incapacidade().matches("p"))
        {
            pg.getChildren().add(st);            
            st = new StaticText();
            st.setId("stTipoIncapacidade");
            st.setEscape(false);
            st.setText("Permanente&nbsp;&nbsp;");            
            pg.getChildren().add(st);
            st = new StaticText();
            st.setId("stTipoIncapacidadeLbl2");
            st.setStyle("font-weight: bold");                        
            st.setEscape(false);
            st.setText("Coeficiente de incapacidade:&nbsp;&nbsp;");            
            pg.getChildren().add(st);            
            st = new StaticText();
            st.setId("stCoefIncapacidade");
            st.setEscape(false);
            st.setText(a.getCoef_incapacidade().toString() + "%");            
            pg.getChildren().add(st);                                    
        }
        
        if(pg.getChildren().size() > 0)
        {
            gridIncapacidade2.getChildren().add(pg);
        }

        pg = new PanelGroup();        
        if(a.getData_aval_incapacidade() != null)
        {

            pg.setId("pgAvaliacaoIncapacidade");
            st = new StaticText();
            st.setId("stDataAvalIncapacidadeLbl1");
            st.setEscape(false);
            st.setText("Avalia&ccedil;&atilde;o de incapacidade realizada em&nbsp;&nbsp;");        
            pg.getChildren().add(st);        
            st = new StaticText();
            st.setId("stDataAvalIncapacidade");
            st.setEscape(false);
            //st.setText(a.getData_aval_incapacidade());        
            try
            {
                java.util.Date ddate = new java.util.Date(a.getData_aval_incapacidade().getTime());
                st.setText(utils.Utils.dateToYYYYMMDD(ddate));            
            }
            catch(Exception ex){};                
            pg.getChildren().add(st);            
        }

        
        if(a.getData_rev_incapacidade() != null)
        {
            st = new StaticText();
            st.setId("stDataRevIncapacidadeLbl1");
            st.setEscape(false);
            st.setText("Revis&atilde;o de incapacidade em&nbsp;&nbsp;");        
            pg.getChildren().add(st);        
            st = new StaticText();
            st.setId("stDataRevIncapacidade");
            st.setEscape(false);
            //st.setText(a.getData_rev_incapacidade());        
            try
            {
                java.util.Date ddate = new java.util.Date(a.getData_rev_incapacidade().getTime());
                st.setText(utils.Utils.dateToYYYYMMDD(ddate));            
            }
            catch(Exception ex){};                        
            pg.getChildren().add(st);                 
        }

        
        if(pg.getChildren().size() > 0)
        {
            gridIncapacidade2.getChildren().add(pg);                   
        }

        
        pg = new PanelGroup();
        
        if(a.getPeriodo_incapacidade_de() != null || a.getPeriodo_incapacidade_a() != null)
        {

            pg.setId("pgPeriodoIncapacidade");        
            st = new StaticText();
            st.setId("stPeriodoIncapacidadeLbl1");
            st.setEscape(false);
            st.setText("Per&iacute;odo de incapacidade tempor&aacute;ria de&nbsp;&nbsp;");
            pg.getChildren().add(st);
            st = new StaticText();
            st.setId("stPeriodoIncapacidadeDe");
            st.setEscape(false);
            //st.setText(a.getPeriodo_incapacidade_de());
            try
            {
                java.util.Date ddate = new java.util.Date(a.getPeriodo_incapacidade_de().getTime());
                st.setText(utils.Utils.dateToYYYYMMDD(ddate));            
            }
            catch(Exception ex){};                        
            pg.getChildren().add(st);
            st = new StaticText();
            st.setId("stPeriodoIncapacidadeLbl2");
            st.setEscape(false);
            st.setText("&nbsp;&nbsp;a&nbsp;&nbsp;");
            pg.getChildren().add(st); 
            st = new StaticText();
            st.setId("stPeriodoIncapacidadeA");
            st.setEscape(false);
            //st.setText(a.getPeriodo_incapacidade_a());
            try
            {
                java.util.Date ddate = new java.util.Date(a.getPeriodo_incapacidade_a().getTime());
                st.setText(utils.Utils.dateToYYYYMMDD(ddate));            
            }
            catch(Exception ex){};                                
            pg.getChildren().add(st);                    
            
        }

        if(pg.getChildren().size() > 0)
        {
            gridIncapacidade2.getChildren().add(pg);            
        }

        
        //RESTRICOES
        
//        if(a.getImg_flexao().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgFlexao");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            pg = new PanelGroup();
//            pg.setId("pgImgFlexao");
//            img = new ImageComponent();
//            img.setId("imgRestricoes1000");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);            
//            img.setUrl("/resources/images/medico/fle1.gif");
//            pg.getChildren().add(img);
//            img = new ImageComponent();
//            img.setId("imgRestricoes1001");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                        
//            img.setUrl("/resources/images/medico/fle2.gif");
//            pg.getChildren().add(img);            
//            img = new ImageComponent();
//            img.setId("imgRestricoes1002");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                        
//            img.setUrl("/resources/images/medico/fle3.gif");
//            pg.getChildren().add(img);            
//            img = new ImageComponent();
//            img.setId("imgRestricoes1003");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                        
//            img.setUrl("/resources/images/medico/fle4.gif");
//            pg.getChildren().add(img);            
//            grd.getChildren().add(pg);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl1");
//            st.setEscape(false);
//            st.setText("Flex&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);
//        }
//        
//        if(a.getImg_rot1().matches("y"))
//        {        
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgRot1");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes1005");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                        
//            img.setUrl("/resources/images/medico/rot1.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl2");
//            st.setEscape(false);
//            st.setText("Flex&atilde;o Lateral");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);            
//        }
//        
//        if(a.getImg_rot2().matches("y"))
//        {        
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgRot2");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes1006");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                        
//            img.setUrl("/resources/images/medico/rot2.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl3");
//            st.setEscape(false);
//            st.setText("Rota&ccedil;&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                        
//        }    
//        
//        if(a.getImg_ext1().matches("y"))
//        {         
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgExt1");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes1007");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ext1.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl4");
//            st.setEscape(false);
//            st.setText("Extens&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                    
//        }       
//        
//        if(a.getImg_ext2().matches("y"))
//        {         
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgExt2");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");   
//            
//            pg = new PanelGroup();
//            pg.setId("pgImgExt2");
//            img = new ImageComponent();
//            img.setId("imgRestricoes1008");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ext2.gif");
//            pg.getChildren().add(img);
//            img = new ImageComponent();
//            img.setId("imgRestricoes1009");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ext3.gif");
//            pg.getChildren().add(img);            
//            img = new ImageComponent();
//            img.setId("imgRestricoes1010");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ext4.gif");
//            pg.getChildren().add(img);            
//            grd.getChildren().add(pg);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl5");
//            st.setEscape(false);
//            st.setText("Flex&atilde;o/Extens&atilde;o Lateral + Rota&ccedil;&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);            
//        }    
//        
//        if(a.getImg_cab1().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgCab1");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10011");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ca1.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl6");
//            st.setEscape(false);
//            st.setText("Flex&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                
//        }
//        
//        if(a.getImg_cab2().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgCab2");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10012");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ca2.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl7");
//            st.setEscape(false);
//            st.setText("Extens&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                            
//        }
//        
//        if(a.getImg_cab3().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgCab3");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10013");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ca3.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl8");
//            st.setEscape(false);
//            st.setText("Flex&atilde;o Lateral");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                        
//        }
//        
//        if(a.getImg_cab4().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgCab4");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10014");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ca4.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl9");
//            st.setEscape(false);
//            st.setText("Rota&ccedil;&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                    
//        } 
//        
//        if(a.getImg_ma1().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa1");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10015");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma1.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl10");
//            st.setEscape(false);
//            st.setText("Porona&ccedil;&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                
//        }
//        
//        if(a.getImg_ma2().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa2");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10016");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma2.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl11");
//            st.setEscape(false);
//            st.setText("Supina&ccedil;&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                            
//        }
//        
//        if(a.getImg_ma3().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa3");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10017");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma3.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl12");
//            st.setEscape(false);
//            st.setText("Flex&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                                        
//        }
//        
//        if(a.getImg_ma4().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa4");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10018");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma4.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl13");
//            st.setEscape(false);
//            st.setText("Extens&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                                                    
//        }
//        
//        if(a.getImg_ma5().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa5");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10019");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma5.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl14");
//            st.setEscape(false);
//            st.setText("Desvio Ulnar");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                                                                
//        }
//        
//        if(a.getImg_ma6().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa6");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10020");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma6.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl15");
//            st.setEscape(false);
//            st.setText("Desvio Radial");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                                                                            
//        }
//        
//        if(a.getImg_ma7().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa7");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10021");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma7.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl16");
//            st.setEscape(false);
//            st.setText("Pin&ccedil;a Digital");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                                                                                        
//        }
//        
//        if(a.getImg_ma8().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa8");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10022");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma8.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl17");
//            st.setEscape(false);
//            st.setText("Segurar objectos entre os dedos");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                                                                                                    
//        }
//        
//        if(a.getImg_ma9().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa9");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10023");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma9.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl18");
//            st.setEscape(false);
//            st.setText("Dedos em extens&atilde;o");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                                                                                                                
//        }
//        
//        if(a.getImg_ma10().matches("y"))
//        {
//            grd = new HtmlPanelGrid();
//            grd.setId("grdImgMa10");
//            grd.setColumns(1);
//            grd.setColumnClasses("gridColCenter");
//            grd.setStyleClass("centerBlock");
//            
//            img = new ImageComponent();
//            img.setId("imgRestricoes10024");
//            img.setWidth(IMAGE_WIDTH);
//            img.setHeight(IMAGE_HEIGHT);                                    
//            img.setUrl("/resources/images/medico/ma10.gif");
//            grd.getChildren().add(img);
//            st = new StaticText();
//            st.setId("stImgRestricaoLbl19");
//            st.setEscape(false);
//            st.setText("Pega palmar");
//            grd.getChildren().add(st);            
//            gridImagesRestricoes.getChildren().add(grd);                                                                                                                                                                                                            
//        } 
//        
//        if(a.getRestricao_carga() != null)
//        {
//            if(a.getRestricao_carga().intValue() > 0)
//            {
//                pg = new PanelGroup();
//                st = new StaticText();
//                st.setId("stRestricaoCargaLbl");
//                st.setEscape(false);
//                st.setText("Movimenta&ccedil;&atilde;o e manipula&ccedil;&atilde;o de cargas com mais de&nbsp;&nbsp;");
//                pg.getChildren().add(st);
//                st = new StaticText();
//                st.setId("stRestricaoCargaKgs");
//                st.setEscape(false);
//                st.setText(a.getRestricao_carga().toString());
//                pg.getChildren().add(st);
//                st = new StaticText();
//                st.setId("stRestricaoCargaLbl1");
//                st.setEscape(false);
//                st.setText("Kg");
//                pg.getChildren().add(st);                
//                gridOutrasRestricoes.getChildren().add(pg);
//            }
//            
//            if(a.getRestricao_motricidade().matches("y"))
//            {
//                st = new StaticText();
//                st.setId("stRestricaoMotricidadeLbl");
//                st.setEscape(false);
//                st.setText("Opera&ccedil;&otilde;es que requeiram motricidade fina.");
//                gridOutrasRestricoes.getChildren().add(st);                
//            }
//            
//            if(a.getRestricao_conducao().matches("y"))
//            {
//                st = new StaticText();
//                st.setId("stRestricaoConducaoLbl");
//                st.setEscape(false);
//                st.setText("Condu&ccedil;&atilde;o/interac&ccedil;&atilde;o com ve&iacute;culos ou outros equipamentos.");
//                gridOutrasRestricoes.getChildren().add(st);                
//            }            
//            
//            if(a.getRestricao_vibracoes().matches("y"))
//            {
//                st = new StaticText();
//                st.setId("stRestricaoVibracoesLbl");
//                st.setEscape(false);
//                st.setText("Utiliza&ccedil;&otilde;o de equipamentos/ferramentas que impliquem exposi&ccedil;&atilde;o a vibra&ccedil;&otilde;es ou impactos.");
//                gridOutrasRestricoes.getChildren().add(st);                
//            }  
//            
//            if(a.getRestricao_outras().trim().length() > 0)
//            {
//                st = new StaticText();
//                st.setId("stRestricaoOutras");
//                st.setEscape(false);
//                st.setText(a.getRestricao_outras());
//                gridOutrasRestricoes.getChildren().add(st);                                
//            }
//            
//            if(a.getMed_observ().trim().length() > 0)
//            {
//                stObservacoes.setText(a.getMed_observ());
//            }
//        }
        
    }    
//    private String getPageFrom(String referer)
//    {
//        String pageFrom = referer.substring(referer.lastIndexOf("/")+1);
//        return pageFrom;
//    }    

//    public String lnkNome_action() {
//        // TODO: Replace with your code
//        RowKey rk = tableRowGroup1.getRowKey();
//        int k = Integer.parseInt(rk.getRowId());        
//        TrabalhadoresListDataProvider provider = (TrabalhadoresListDataProvider) tableRowGroup1.getSourceData();
//        ArrayList list = (ArrayList) provider.getList();
//        Trabalhador t = (Trabalhador)list.get(k);
//        txtTrabalhador.setText(t.getNome());     
//        txtNomeAcidentado.setText(t.getNome());
//        txtDataNascimento.setText(t.getData_nascimento());     
//        Acidentado a = new Acidentado();
//        a.setTrabalhador_id(t.getId());
//        a.setData_nascimento(t.getData_nascimento());
//        a.setNome(t.getNome());  
//        a.setFuncao(utils.Utils.unicodeToHTML(t.getFuncao()));
//        a.setData_admissao(t.getData_admissao());        
//        getSessionBean1().setAcidentado(a);
//        if(getSessionBean1().getCurrentAnalise() != null) // new analise)
//        {
//            gridTrabalhadores.setRendered(false);
//        }
//        
//        return null;
//    }

//    public String lnkDataNascimento_action() {
//        // TODO: Replace with your code
//        RowKey rk = tableRowGroup1.getRowKey();
//        int k = Integer.parseInt(rk.getRowId());        
//        TrabalhadoresListDataProvider provider = (TrabalhadoresListDataProvider) tableRowGroup1.getSourceData();
//        ArrayList list = (ArrayList) provider.getList();
//        Trabalhador t = (Trabalhador)list.get(k);
//        txtTrabalhador.setText(t.getNome());
//        txtNomeAcidentado.setText(t.getNome());
//        txtDataNascimento.setText(t.getData_nascimento());
//        Acidentado a = new Acidentado();
//        a.setTrabalhador_id(t.getId());
//        a.setData_nascimento(t.getData_nascimento());
//        a.setNome(t.getNome());
//        a.setFuncao(t.getFuncao());
//        a.setData_admissao(t.getData_admissao());
//        getSessionBean1().setAcidentado(a); 
//        if(getSessionBean1().getCurrentAnalise() != null) // new analise)
//        {
//            gridTrabalhadores.setRendered(false);
//        }
//        return null;
//    }
    
    private void fillVerificacao(AnaliseAcidente a)
    {
        int estado = a.getEstado().intValue();
        switch(estado)
        {
            case Global.ESTADO_ASSINATURA_SEG:
                if(a.getAss_resp_seg().matches("y"))
                {
                   chkVerRespSeg.setSelected(new Boolean(true));
                   chkVerRespSeg.setDisabled(true);
                    java.util.Date ddate = new java.util.Date(a.getData_assinatura_seg().getTime());
                    stVerRespSeg.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate));            
                }
                break;
                
            case Global.ESTADO_ASSINATURA_RH:
                if(a.getAss_resp_rh().matches("y"))
                {
                   chkVerRespRh.setSelected(new Boolean(true));
                   chkVerRespRh.setDisabled(true);
                    java.util.Date ddate = new java.util.Date(a.getData_assinatura_rh().getTime());
                    stVerRespRh.setText("Tomei conhecimento a " + utils.Utils.dateToYYYYMMDD(ddate));            
                }
                
                break;
        }
    }
    
    private void fillVerificacaoView(AnaliseAcidente a)
    {
        StaticText st = null;
        String txtVer = null;        
        if(a.getAveriguador() != null)
        {
            if(a.getAveriguador().trim().length() > 0)
            {
                st = new StaticText();
                st.setId("stVerificacao1");
                st.setEscape(false);
                txtVer = "Averiguado por " + a.getAveriguador() + " (Departamento de Seguran&ccedil;a) a ";
                //txtVer += a.getData_assinatura_seg();

                try
                {
                    java.util.Date ddate = new java.util.Date(a.getData_inicio_processo().getTime());
                    txtVer += utils.Utils.dateToYYYYMMDD(ddate) + ".";            
                }  
                catch(Exception ex){};                  
                st.setText(txtVer);
                gridAssinaturasView.getChildren().add(st);
            }
        }
        
        if(a.getAss_consolidacao().matches("y"))
        {
            st = new StaticText();
            st.setId("stVerificacao2");
            st.setEscape(false);
            txtVer = "Verificado por " + a.getNome_resp_consolidacao() + " (T&eacute;cnico de SHST) a ";
            //txtVer += a.getData_assinatura_rh();        
            try
            {
                java.util.Date ddate = new java.util.Date(a.getData_consolidacao().getTime());
                txtVer += utils.Utils.dateToYYYYMMDD(ddate) + ".";            
            }  
            catch(Exception ex){};                          
            st.setText(txtVer);  
            gridAssinaturasView.getChildren().add(st);                                
        }
        
        if(a.getAss_resp_seg().matches("y"))
        {
            st = new StaticText();
            st.setId("stVerificacao3");
            st.setEscape(false);
            txtVer = "Verificado por " + a.getNome_resp_seg() + " (Respons&aacute;vel de Seguran&ccedil;a) a ";
            //txtVer += a.getData_assinatura_rh();        
            try
            {
                java.util.Date ddate = new java.util.Date(a.getData_assinatura_seg().getTime());
                txtVer += utils.Utils.dateToYYYYMMDD(ddate) + ".";            
            }  
            catch(Exception ex){};                          
            st.setText(txtVer);  
            gridAssinaturasView.getChildren().add(st);                    
        }

        if(a.getAss_resp_rh().matches("y"))
        {
            st = new StaticText();
            st.setId("stVerificacao4");
            st.setEscape(false);
            txtVer = "Verificado por " + a.getNome_resp_rh() + " (Respons&aacute;vel de RH) a ";
            //txtVer += a.getData_assinatura_rh();        
            try
            {
                java.util.Date ddate = new java.util.Date(a.getData_assinatura_rh().getTime());
                txtVer += utils.Utils.dateToYYYYMMDD(ddate) + ".";            
            }  
            catch(Exception ex){};                          
            st.setText(txtVer);  
            gridAssinaturasView.getChildren().add(st);        
        }
        
        AnalisesDataProvider adp = new AnalisesDataProvider();
        try
        {
            Acidentado ac = adp.getAcidentado(a.getAcidentado_id());
            if(ac.getNome_superior_hierarquico() != null)
            {
                if(ac.getNome_superior_hierarquico().trim().length() > 0)
                {
                    st = new StaticText();
                    st.setId("stVerificacao5");
                    st.setEscape(false);
                    txtVer = "Com conhecimento de " + ac.getNome_superior_hierarquico() + " (Respons&aacute;vel hier&aacute;rquico)";
                    
                    if(ac.getEmail_superior_hierarquico() != null)
                    {
                        if(ac.getEmail_superior_hierarquico().trim().length() > 0)
                        {
                            try
                            {
                                java.util.Date ddate = new java.util.Date(ac.getData_email_superior_hierarquico().getTime());
                                txtVer += " a " + utils.Utils.dateToYYYYMMDD(ddate);            
                            }  
                            catch(Exception ex){};                          
                        }
                    }
                    txtVer += ".";
                    st.setText(txtVer);  
                    gridAssinaturasView.getChildren().add(st);                            
                }
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        
        HtmlPanelGrid grid = new HtmlPanelGrid();
        grid.setId("rodape1");
        grid.setColumns(1);
        grid.setStyle("width: 100%");
        grid.setColumnClasses("gridColCenter");
        st = new StaticText();
        st.setId("stRodape1");
        st.setEscape(false);
        st.setText("- processamento inform&aacute;tico - acesso autenticado -");
        grid.getChildren().add(st);
        gridAssinaturasView.getChildren().add(grid);                        
    }
    
    
    private AnaliseAcidente fillAnaliseFieldsImpressao(AnaliseAcidente a)
    {
        a.setAss_superior("n");        
        if(chkAssSup.getSelected() != null)
        {
            if(chkAssSup.getSelected().equals(new Boolean(true)))
            {
                 a.setAss_superior("y");
            }
        }
        
        if(a.getAss_superior().matches("y"))
        {
            a.setNome_superior("");
            if(txtAssSup.getText() != null)
            {
                a.setNome_superior( (String) txtAssSup.getText());
            }
            java.util.Date today =
                            new java.util.Date();
            java.sql.Date sqlToday =
                            new java.sql.Date(today.getTime());  
            a.setData_assinatura_superior(sqlToday);            
        }
        else
        {
            a.setNome_superior("");
            a.setData_assinatura_superior(null);
        }
        return a;
    }
    
    private void fillImpressao(AnaliseAcidente a)
    {
        if(a.getAss_superior().matches("y"))
        {
            chkAssSup.setSelected(new Boolean(true));
            txtAssSup.setText(a.getNome_superior());
            String txt = (String) stAssSup2.getText();
            String nome_acidentado = getSessionBean1().getAcidentado().getNome();
            String stData = "";
            try
            {
                java.util.Date ddate = new java.util.Date(a.getData_assinatura_superior().getTime());
                stData += utils.Utils.dateToYYYYMMDD(ddate);            
            }  
            catch(Exception ex){};                                      
            stAssSup2.setText(txt + nome_acidentado + ", a " + stData);
        }

    }
    
    private void fillImpressaoView(AnaliseAcidente a)
    {
        StaticText st = new StaticText();
        st.setId("stImpressaoView1");
        st.setEscape(false);
        String stData = "";
        try
        {
            java.util.Date ddate = new java.util.Date(a.getData_assinatura_superior().getTime());
            stData += utils.Utils.dateToYYYYMMDD(ddate);            
        }  
        catch(Exception ex){};                                              
        
        String txt = "Assinado na Ficha de An&aacute;lise de Acidente em papel por " + a.getNome_superior() + ", superior hier&aacute;rquico / superior de ";
        txt += getSessionBean1().getAcidentado().getNome() + ", a " + stData;
        gridAssSupView.getChildren().add(st);
    }    

    public String butImagem_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        getSessionBean1().setIeBug(true);        
        savePageState();
        return "load_image";
    }
    
    private void fillImages()
    {
//        String imageName = getSessionBean1().getImageName();
//        if(imageName != null)
//        {
//            ImageComponent newImg = new ImageComponent();
//            newImg.setUrl("/resources/imagens/" + imageName);
//            System.out.println("IMAGE URL : " + "/resources/imagens/" + imageName);            
//            newImg.setRendered(true);
//            gridImages.getChildren().add(newImg);
//            System.out.println("HERE");
//        }
//        if(gridImages.getChildren().size() > 0)
//        {
//            gridImages.getChildren().clear();
//        }
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
        
        
        File apacheTmpFolder = new File(theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/tmp" + getSessionBean1().getCurrentUser().getLogin());
        if(apacheTmpFolder.exists())
        {
            Global global = new Global();
            global.deleteFolderFiles(apacheTmpFolder);
        }
        else
        {
            apacheTmpFolder.mkdir();            
        }
        
//         String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin());        
         String imageFileFolder = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin();                
         try
         {
            File f = new File(imageFileFolder);

            if(f.exists())
            {
                File files[] = f.listFiles();
                //List list = Arrays.asList(files);
                Arrays.sort(files);
                for(int i=0;i<files.length;i++)
                {
                    if(files[i].isFile())       
                    {
                        String imageName = files[i].getName();

                        File apacheImage = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/tmp" + getSessionBean1().getCurrentUser().getLogin() + "/" + imageName);
                        Global global = new Global();
                        global.copyImage(files[i], apacheImage);
                        
                        ImageComponent newImg = new ImageComponent();
                        newImg.setId("img_comp" + imageName);                        
                        //newImg.setUrl(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin() + "/" + imageName);
                        newImg.setUrl(Global.RESOURCES_IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin() + "/" + imageName);
                        //System.out.println("IMAGE URL : " + newImg.getUrl());                                                
                        newImg.setRendered(true);
                        gridImages.getChildren().add(newImg);
                        
                        
                        Hyperlink ln = new Hyperlink();
                        ln.setId("img" + imageName); 
                        ln.setText("Apagar");
                        //ln.setValue(imageName);
                        Class args[] = { javax.faces.event.ActionEvent.class }; 
                        ApplicationFactory factory = (ApplicationFactory)

                        FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
                        //mb = factory.getApplication().createMethodBinding( "#{EditarQuestionario.lnkGrupo_onClick}", args);                        
                        MethodBinding mbAction = (MethodBinding) factory.getApplication().createMethodBinding("#{AnaliseAcidenteTrabalho.lnkDelImageTmp_actionListener}", args);
                        ln.setActionListener(mbAction); 
                        gridImages.getChildren().add(ln);                        
                    }
                }                
            }
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }        

    }

    public String butCancelar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        getSessionBean1().setIeBug(true);        
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
//        String imageFileFolderTmp = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin());        
        String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin();                

        File ftmp = new File(imageFileFolderTmp);
        if( ftmp.exists() )
        {
            File files[] = ftmp.listFiles();

            for(int i=0;i<files.length;i++)
            {
                if(files[i].isFile())       
                {
                    files[i].delete();
                }
            }  
            
            ftmp.delete();
        }
        String navFrom = getSessionBean1().getNavFrom();
        if(navFrom.matches("FormSeguranca"))
        {
            return "form_seguranca";
        }
        else if(navFrom.matches("FormRH"))
        {
            return "form_rh";
        }        
        else if(navFrom.matches("FormHS"))
        {
            return "form_hs";
        }                
        else if(navFrom.matches("FormMedico"))
        {
            return "form_medico";
        }
        return null;
    }

    
    public String butGravar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        
        System.out.println("BUT GRAVAR");
        
        if(getSessionBean1().getCurrentAnalise() == null) //new analise
        {
            //if(validationOk())
            //{
              if(validationDepartmentSectionOk())  
              {
                AnaliseAcidente a = fillAnaliseFields();
                Acidentado ac = fillAcidentadoFields();                    
                if(fieldsLenOk())
                {
                    try
                    {
                        if(!getSessionBean1().isGravado())
                        {
                            getSessionBean1().setGravado(true);
                            AnaliseAcidente aa = create(a, ac);   
                            createImagesFolder(aa);
                            getSessionBean1().setMsg("A Ficha de An&aacute;lise de Acidente n&#186; " + aa.getAnalise_nr() + " foi gravada na sua &aacute;rea de trabalho.");
                        }
                        else
                        {
                            getSessionBean1().setMsg("A Ficha de An&aacute;lise de Acidente foi gravada na sua &aacute;rea de trabalho.");                        
                        }
                        String navFrom = getSessionBean1().getNavFrom();
                        if(navFrom.matches("FormSeguranca"))
                        {
                            return "form_seguranca";
                        }                                              

                    }
                    catch(Exception ex)
                    {
                        getSessionBean1().setMsg("Erro na inser&ccedil;&atilde;o da an&aacute;lise !");
                        getSessionBean1().setGravado(false);                    
                        ex.printStackTrace();
                    }                    
                }

            } 
            else
            {
                getSessionBean1().setGravado(false);                  
            }
        }
        else    // edit analise
        {
            if(fieldsLenOk())
            {

                AnaliseAcidente a = fillAnaliseFields();
                Acidentado ac = null;
                ArrayList recs = null;
                ArrayList meds = null;
                int estado = a.getEstado().intValue();
                //if(estado == ESTADO_SEG || estado == ESTADO_RH1)
                if(estado == Global.ESTADO_RH1)                
                {
                    ac = fillAcidentadoFields();                    
                }
                else if(estado == Global.ESTADO_HS)
                {
                    a.setTecnico_saude_id(getSessionBean1().getCurrentUser().getId());            
                    recs = fillAnaliseRecomendacoesHs(a);
                }
                else if(estado == Global.ESTADO_RH2)
                {
                    meds = fillAnaliseMedidasRh(a);
                    a.setRh_fase4(getSessionBean1().getCurrentUser().getId());
                }
                try
                {
                    if(! getSessionBean1().isGravado())
                    {
                        getSessionBean1().setGravado(true);
                        update(a, ac, recs, meds);                
                        //createImagesFolder(analiseId.toString());
                        updateImagesFolder(a);
                        getSessionBean1().setMsg("A Ficha de An&aacute;lise de Acidente n&#186; " + a.getAnalise_nr() + " foi gravada na sua &aacute;rea de trabalho.");                    
                    }
                    else
                    {
                        getSessionBean1().setMsg("A Ficha de An&aacute;lise de Acidente n&#186; " + a.getAnalise_nr() + " foi gravada na sua &aacute;rea de trabalho.");                                                                
                    }

                    if(estado != Global.ESTADO_ASSINATURA_RH)
                    {
                        String navFrom = getSessionBean1().getNavFrom();
                        if(navFrom.matches("FormSeguranca"))
                        {
                            return "form_seguranca";
                        }       
                        else if(navFrom.matches("FormRH"))
                        {
                            return "form_rh";                        
                        }
                        else if(navFrom.matches("FormHS"))
                        {
                            return "form_hs";                        
                        }                                        
                        else if(navFrom.matches("FormMedico"))
                        {
                            return "form_medico";                        
                        }                                                            
                    }
                    else
                    {
                        chkVerRespRh.setDisabled(true);
                        // IMPRIMIR HERE
                    }                        
                    

                }
                catch(Exception ex)
                {
                    getSessionBean1().setMsg("Erro na actualiza&ccedil;&atilde;o da an&aacute;lise !");
                    getSessionBean1().setGravado(false);                                      
                    ex.printStackTrace();
                }
            }                        
        }
        

        return null;
    }
    
    public String butEnviar_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        
        System.out.println("BUT ENVIAR 1");
        
        //IE bugs
        if(getSessionBean1().isIeBug())
        {
            return null;
        }
        if(getSessionBean1().isGravado() )
        {
            getSessionBean1().setSubmetido(true);
        }
        
        //
        if(getSessionBean1().getCurrentAnalise() == null) //new analise
        {
            if(validationOk())
            {
                AnaliseAcidente a = fillAnaliseFields();
                Acidentado ac = fillAcidentadoFields();
                //int novo_estado = a.getEstado().intValue();
                a.setEstado(new Integer(Global.ESTADO_RH1));                
                try
                {
                    if(!getSessionBean1().isSubmetido())
                    {
                        getSessionBean1().setSubmetido(true);
                        AnaliseAcidente aa = create(a, ac);                
                        createImagesFolder(aa);
                        sendMailToNextUser(a, new Integer(Global.ESTADO_RH1));
                        getSessionBean1().setMsg("A Ficha de An&aacute;lise de Acidente n&#186; " + aa.getAnalise_nr() + " foi enviada para a fase seguinte.");
                    }
                    else
                    {
                        getSessionBean1().setMsg("A Ficha de An&aacute;lise de Acidente foi enviada para a fase seguinte.");                        
                    }
                    String navFrom = getSessionBean1().getNavFrom();
                    if(navFrom.matches("FormSeguranca"))
                    {
                        return "form_seguranca";
                    }                                        
                    

                }
                catch(Exception ex)
                {
                    getSessionBean1().setMsg("Erro no envio da an&aacute;lise !");
                    getSessionBean1().setSubmetido(false);                    
                    ex.printStackTrace();
                }
            } 
            else
            {
                getSessionBean1().setSubmetido(false);                      
            }
        }
        else    // edit analise
        {
            if(validationOk())
            {
                AnaliseAcidente a = fillAnaliseFields();
                Acidentado ac = null;
                ArrayList recs = null;
                ArrayList meds = null;
                int estado = a.getEstado().intValue();
                //if(estado == ESTADO_SEG || estado == ESTADO_RH1)
                if(estado == Global.ESTADO_RH1)                
                {
                    ac = fillAcidentadoFields();                    
                }         
                else if(estado == Global.ESTADO_HS)
                {
                    a.setTecnico_saude_id(getSessionBean1().getCurrentUser().getId());                                
                    recs = fillAnaliseRecomendacoesHs(a);
                }        
                else if(estado == Global.ESTADO_RH2)
                {
                    meds = fillAnaliseMedidasRh(a);
                    a.setRh_fase4(getSessionBean1().getCurrentUser().getId());                    
                }                
                int novo_estado = a.getEstado().intValue();
                
                if(a.getCorrecao().matches("y"))
                {
                    a.setCorrecao("n");
                    a.setEstado(a.getEstado_antes_correcao());
                    novo_estado = a.getEstado_antes_correcao().intValue();
                    a.setEstado_antes_correcao(null);
                    a.setObservacoes_correcao("");
                    //sendMailToNextUser(a, new Integer(novo_estado));                    
                }
                else
                {
                    if(novo_estado < Global.ESTADO_CONCLUIDO)
                    {
                        if(!getSessionBean1().isSubmetido())
                        {
                            novo_estado++;                            
                        }

    //                    if(novo_estado == ESTADO_MEDICO)
    //                    {
    //                        novo_estado++;  //skip medico
    //                    }
//                        if(novo_estado == Global.ESTADO_ASSINATURA_SEG || novo_estado == Global.ESTADO_ASSINATURA_RH)
//                        {
//                            //a.setEstado_assinatura(new Integer(ESTADO_ASSINATURA_1));
//                            notifyNextSignature(new Integer(novo_estado));                        
//                        }
                    }
                    a.setEstado(new Integer(novo_estado));                     
                }

                try
                {
                    if(!getSessionBean1().isSubmetido())
                    {
                        getSessionBean1().setSubmetido(true);
                        update(a, ac, recs, meds);                
                        //createImagesFolder(analiseId.toString());
                        updateImagesFolder(a); 
                        sendMailToNextUser(a, new Integer(novo_estado));                        
                        //envia email para responsavel hierarquico ao passar da Consolidacao para a Verificacao
                        if(a.getEstado().intValue() == Global.ESTADO_ASSINATURA_SEG)
                        {
                            sendEmailResponsavelHierarquico(a);
                        }
                        else if(a.getEstado().intValue() == Global.ESTADO_CONCLUIDO)
                        {
                            sendEmailFimProcesso(a);
                            sendEmailToRhFase4(a);
                        }
                        getSessionBean1().setMsg("A Ficha de An&aacute;lise de Acidente n&#186; " + a.getAnalise_nr() + " foi enviada para a fase seguinte.");                    
                    }
                    else
                    {
                        getSessionBean1().setMsg("A Ficha de An&aacute;lise de Acidente n&#186; " + a.getAnalise_nr() + " foi enviada para a fase seguinte.");                                            
                    }
                    String navFrom = getSessionBean1().getNavFrom();
                    if(navFrom.matches("FormSeguranca"))
                    {
                        return "form_seguranca";
                    }     
                    else if(navFrom.matches("FormRH"))
                    {
                        return "form_rh";                        
                    }
                    else if(navFrom.matches("FormHS"))
                    {
                        return "form_hs";                        
                    }                                        
                    else if(navFrom.matches("FormMedico"))
                    {
                        return "form_medico";                        
                    }                                                                                                                            

                }
                catch(Exception ex)
                {
                    getSessionBean1().setMsg("Erro na actualiza&ccedil;&atilde;o da an&aacute;lise !");
                    getSessionBean1().setSubmetido(false);                          
                    ex.printStackTrace();
                }
            }
            else
            {
                getSessionBean1().setSubmetido(false);                      
            }
        }        
        
        return null;
    }    
    
    
    private AnaliseAcidente create(AnaliseAcidente a, Acidentado ac) throws Exception
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        Integer acidentado_id = adp.createAcidentado(ac);        
        a.setAcidentado_id(acidentado_id);
        AnaliseAcidente aa = adp.createAnalise(a);    


        return aa;
    }
    
    private void update(AnaliseAcidente a, Acidentado ac, ArrayList recs, ArrayList meds) throws Exception
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        if(ac != null)
        {
            adp.updateAcidentado(ac);            
        }
        if(recs != null)
        {
            //remove recs form analise
            try
            {
                adp.deleteRecomendacoesByAnalise(a.getId());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
            ListIterator iter = recs.listIterator();
            while(iter.hasNext())
            {
                Recomendacao r = (Recomendacao)iter.next();
                adp.createRecomendacao(r);
            }
        }
        else if(meds != null)
        {
            //remove meds form analise
            try
            {
                adp.deleteMedidasByAnalise(a.getId());
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
            ListIterator iter = meds.listIterator();
            while(iter.hasNext())
            {
                Medida m = (Medida)iter.next();
                adp.createMedida(m);
            }            
        }
        adp.updateAnalise(a);    
    }
    
    private Acidentado fillAcidentadoFields()
    {
        Acidentado a = getSessionBean1().getAcidentado();
        a.setBilhete_identidade("");
        if(txtBI.getText() != null)
        {
            String bi = (String) txtBI.getText();
            if(bi.trim().length() > 0)
            {
                a.setBilhete_identidade(bi);                
            }
        }

        a.setMorada("");
        if(txtMorada.getText() != null)
        {
            String morada = (String) txtMorada.getText();
            if(morada.trim().length() > 0)
            {
                a.setMorada( morada );                
            }
        }

        a.setCod_postal("");
        String cod_postal = "";
        if(txtCodPostal1.getText() != null )
        {
            String cod_postal1 = (String) txtCodPostal1.getText();
            String cod_postal2 = "";
            if(txtCodPostal2.getText() != null)
            {
                cod_postal2 = (String) txtCodPostal2.getText();
            }
            if(cod_postal1.trim().length() > 0)
            {
                cod_postal =(String) txtCodPostal1.getText() + "-" + (String) txtCodPostal2.getText();                            
                a.setCod_postal( cod_postal);                
            }

        }

        a.setLocalidade("");
        if(txtLocalidade.getText() != null)
        {
            String localidade = (String) txtLocalidade.getText();
            if(localidade.trim().length() > 0)
            {
                a.setLocalidade( localidade);                
            }
        }

        a.setContacto_telefonico("");
        if(txtContactoTelefonico.getText() != null)
        {
            String contacto_telefonico = (String) txtContactoTelefonico.getText();
            if(contacto_telefonico.trim().length() > 0)
            {
                a.setContacto_telefonico( contacto_telefonico );                
            }
        }

        
        a.setTurno("v"); // null
        if(rbTurnoManha.getValue() != null)
        {
            if(rbTurnoManha.getValue().equals(new Boolean(true)))
            {
                a.setTurno("m");
            }
        }
        if(rbTurnoTarde.getValue() != null)
        {
            if(rbTurnoTarde.getValue().equals(new Boolean(true)))
            {
                a.setTurno("t");
            }                        
        }
        if(rbTurnoNoite.getValue() != null)
        {
            if(rbTurnoNoite.getValue().equals(new Boolean(true)))
            {
                a.setTurno("n");
            }                        
        }
        
        if(txtNomeSuperior.getText() != null)
        {
            a.setNome_superior_hierarquico((String) txtNomeSuperior.getText());
        }
        
        if(txtEmailSuperior.getText() != null)
        {
            a.setEmail_superior_hierarquico((String) txtEmailSuperior.getText());
            java.util.Date today =
                            new java.util.Date();
            java.sql.Date sqlToday =
                            new java.sql.Date(today.getTime());  
            a.setData_email_superior_hierarquico(sqlToday);                        
        }

        return a;
    }
    
    private AnaliseAcidente fillAnaliseFields()
    {
        int estado = 0;
        AnaliseAcidente a = null;
        //fill analise fields
        if(getSessionBean1().getCurrentAnalise() == null)  //null
        {
            a = new AnaliseAcidente(); 
            a.setEspecif1("");
            a.setEspecif2("");            
            a.setEspecif3("");            
            a.setEspecif4("");       
            a.setRestricao_outras("");
            a.setTipo_lesao("");
            a.setMed_observ("");
            estado = Global.ESTADO_SEG;
            a.setEstado(new Integer(estado));              
        }
        else
        {
            a = getSessionBean1().getCurrentAnalise();
            estado = a.getEstado().intValue();
        }
        
        
        //averiguacao posterior
//        if(estado < Global.ESTADO_ASSINATURAS)
        if(estado < Global.ESTADO_ASSINATURA_SEG)        
        {
            if(getSessionBean1().getCurrentUser().getTipo().intValue() == 1) //seguranca
            {
                if(a.getAveriguacao_posterior().matches("y"))
                {
                    if(txtAveriguacaoObs1.getText() != null)
                    {
                        a.setAveriguacao_obs((String) txtAveriguacaoObs1.getText());                                
                    }

                }
            }
        }
      
        switch(estado)
        {
            case Global.ESTADO_SEG:
                a = fillAnaliseFieldsSeg(a);
                break;
            case Global.ESTADO_RH1:
                //a = fillAnaliseFieldsSeg(a);                
                a = fillAnaliseFieldsRH1(a);                
                break;     
            case Global.ESTADO_HS:
                //a = fillAnaliseFieldsHS(a);                
                break;    
            case Global.ESTADO_RH2:
                a = fillAnaliseFieldsMedico(a);                  
                //a = fillAnaliseFieldsRH2(a);
                break;     
//            case Global.ESTADO_MEDICINA:
//                a = fillAnaliseFieldsMedico(a);                 
//                break;  
            case Global.ESTADO_CONSOLIDACAO:
                a = fillAnaliseFieldsConsolidacao(a);
                break;
//            case Global.ESTADO_ASSINATURAS:
            case Global.ESTADO_ASSINATURA_SEG:                
                a = fillAnaliseAssinaturas(a);
                break;
            case Global.ESTADO_ASSINATURA_RH:                
                a = fillAnaliseAssinaturas(a);
                break;
                
        }
        
        return a;
    }
    
    private AnaliseAcidente fillAnaliseFieldsSeg(AnaliseAcidente a)
    {
        if(txtAveriguador.getText() != null)
        {
            a.setAveriguador((String) txtAveriguador.getText());
        }

        java.util.Date today =
                        new java.util.Date();
        java.sql.Date sqlToday =
                        new java.sql.Date(today.getTime());          
        //if(a.getData_acidente() == null)
        //{
        //    a.setData_acidente(sqlToday);
        //}
        //else
        //{
            DateFormat formatador = new SimpleDateFormat("yyyy-MM-dd");

            java.util.Date ddate  = (java.util.Date) calDataOcorrencia.getValue();
            try
            {
                String ddate_str = formatador.format(ddate);             
                java.sql.Date ddate_sql = new java.sql.Date(formatador.parse(ddate_str).getTime());                        
                a.setData_acidente(ddate_sql);
            }
            catch(Exception ex)
            {
                a.setData_acidente(null);                        
            }                            
        //}
        
        if(a.getData_inicio_processo() == null)
        {
            a.setData_inicio_processo(sqlToday);            
        }
        
        Integer hhInt = (Integer) drpHours.getSelected();
        Integer mmInt = (Integer) drpMinutes.getSelected();
        
        if(hhInt.intValue() == -1 || mmInt.intValue() == -1)
        {
            a.setHora_acidente(null);
        }
        else
        {
//            String hh = drpHours.getSelected().toString();
//            String mm = drpMinutes.getSelected().toString();        
            String hh = hhInt.toString();
            String mm = mmInt.toString();
            SimpleDateFormat formatter = new SimpleDateFormat ( "hh:mm" ); 
            try
            {
                Time horaAcidente = new Time(formatter.parse( hh + ":" + mm ).getTime());                     
                a.setHora_acidente(horaAcidente);
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
            
        }

        
        
        if(getSessionBean1().getCurrentAnalise() == null)   // new
        {
            a.setEmpresa_id(getSessionBean1().getCurrentUser().getEmpresa_id());                        
            a.setEstabelecimento_id(getSessionBean1().getCurrentUser().getEstabelecimento_id());            
        }

//        Integer medico_id = (Integer) drpMedicos.getSelected();
        Medico m = getSessionBean1().getMedico();
        if(m != null)
        {
            Integer medico_id = m.getId();            
            if(medico_id.intValue() > 0)
            {
                a.setMedico_id(medico_id);            
            }
            
        }

        Integer horas_turno = null;
        try
        {
            String horas_turno_str = (String) txtHorasTurno.getText();
            horas_turno = new Integer( Integer.parseInt(horas_turno_str) );
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        a.setHoras_turno(horas_turno);                        

//        try
//        {
//            if(txtSeccao.getText() != null)
//            {
//                a.setSeccao( (String) txtSeccao.getText() );                    
//            }
//            else
//            {
//                a.setSeccao("");                    
//            }
//        }
//        catch(Exception ex)
//        {
//            ex.printStackTrace();
//        }
        
        a.setDepartamento_id(( Integer ) drpDepartamento.getSelected());
        a.setSeccao_id((Integer) drpSeccao.getSelected());        

        try
        {
            if(txtLocal.getText() != null)
            {
                a.setLocal_trabalho( (String) txtLocal.getText() );                    
            }
            else
            {
                a.setLocal_trabalho("");                    
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }   

        try
        {
            if(txtTarefa.getText() != null)
            {
                a.setTarefa( (String) txtTarefa.getText() );                    
            }
            else
            {
                a.setTarefa("");                    
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }  

        try
        {
            if(txtSubstancias.getText() != null)
            {
                a.setSubstancias( (String) txtSubstancias.getText() );                    
            }
            else
            {
                a.setSubstancias("");
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        } 

//        try
//        {
//            if(txtSuperior.getText() != null)
//            {
//                a.setSuperior_hierarquico( (String) txtSuperior.getText() );                    
//            }
//            else
//            {
//                a.setSuperior_hierarquico("");
//            }
//        }
//        catch(Exception ex)
//        {
//            ex.printStackTrace();
//        }    

        try
        {
            if(txtCondicoes.getText() != null)
            {
                a.setCondicoes( (String) txtCondicoes.getText() );                    
            }
            else
            {
                a.setCondicoes("");                    
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }  

        try
        {
            if(txtTestemunhas.getText() != null)
            {
                a.setTestemunhas( (String) txtTestemunhas.getText() );                    
            }
            else
            {
                a.setTestemunhas("");                    
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }      

//        try
//        {
//            if(txtCausas.getText() != null)
//            {
//                a.setCausas( (String) txtCausas.getText() );                    
//            }
//            else
//            {
//                a.setCausas("");                    
//            }
//        }
//        catch(Exception ex)
//        {
//            ex.printStackTrace();
//        }     
        
        a.setCausas((Integer) drpCausas.getSelected());
        
        try
        {
            if(txtDescricao.getText() != null)
            {
                a.setDescricao( (String) txtDescricao.getText() );                    
            }
            else
            {
                a.setDescricao("");                    
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }  

        try
        {
            if(txtConclusoes.getText() != null)
            {
                a.setConclusoes( (String) txtConclusoes.getText() );                    
            }
            else
            {
                a.setConclusoes("");                    
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        } 

        try
        {
            if(txtAccoes.getText() != null)
            {
                a.setAccoes( (String) txtAccoes.getText() );                    
            }
            else
            {
                a.setAccoes("");                    
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }     
        
        a.setAveriguacao_posterior("n");        
        if(chkAveriguacaoPosterior.getSelected() != null)
        {
            if(chkAveriguacaoPosterior.getSelected().equals(new Boolean(true)))
            {
                a.setAveriguacao_posterior("y");
            }
        }
        
        if(txtAveriguacaoObs.getText() != null)
        {
            a.setAveriguacao_obs((String) txtAveriguacaoObs.getText());
        }
        return a;
    }
    
    private AnaliseAcidente fillAnaliseFieldsRH1(AnaliseAcidente a)
    {
        boolean booFormacaoSHST = false;
        if(rbFormacaoSHSTY.getSelected() != null)
        {
            Boolean f = (Boolean) rbFormacaoSHSTY.getSelected();
            if(f.equals(new Boolean(true)))
            {
                a.setFormacao_shst("y");
                booFormacaoSHST = true;
            }
        }

        if(!booFormacaoSHST)
        {
            if(rbFormacaoSHSTN.getSelected() != null)
            {
                Boolean f = (Boolean) rbFormacaoSHSTN.getSelected();
                if(f.equals(new Boolean(true)))
                {
                    a.setFormacao_shst("n");
                    a.setFormacao_shst_nao_porque("");
                    if(txtFormacaoSHSTNWhy.getText() != null)
                    {
                        String s = (String) txtFormacaoSHSTNWhy.getText();
                        if(s.trim().length() > 0 )
                        {
                            a.setFormacao_shst_nao_porque( s );                        
                        }
                    }                    
                }
            }
            else
            {
                a.setFormacao_shst("t");
            }            
        }
        
        boolean booAcidentesColaborador = false;
        a.setOutros_acidentes_com_colaborador("n");
        if(rbAcidentesColaboradorY.getSelected() != null)
        {
            Boolean f = (Boolean) rbAcidentesColaboradorY.getSelected();
            if(f.equals(new Boolean(true)))
            {
                a.setOutros_acidentes_com_colaborador("y");
                booAcidentesColaborador = true;
                if(txtNrAcidentesColaborador.getText() != null)
                {
                    String nr_str = (String) txtNrAcidentesColaborador.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_acidentes_com_colaborador(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }
                }
                
                if(txtNrRelatorioAcidentesColaborador1.getText() != null)
                {
                    String nr_str = (String) txtNrRelatorioAcidentesColaborador1.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_relatorio_acidente_colaborador1(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }                    
                }
                if(txtNrRelatorioAcidentesColaborador2.getText() != null)
                {
                    String nr_str = (String) txtNrRelatorioAcidentesColaborador2.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_relatorio_acidente_colaborador2(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }                    
                }  
                if(txtNrRelatorioAcidentesColaborador3.getText() != null)
                {
                    String nr_str = (String) txtNrRelatorioAcidentesColaborador3.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_relatorio_acidente_colaborador3(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }                    
                }                
                if(txtNrRelatorioAcidentesColaborador4.getText() != null)
                {
                    String nr_str = (String) txtNrRelatorioAcidentesColaborador4.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_relatorio_acidente_colaborador4(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }                    
                }                                
            }
        }
        
        if(!booAcidentesColaborador)
        {
            if(rbAcidentesColaboradorN.getSelected() != null)            
            {
                Boolean f = (Boolean) rbAcidentesColaboradorN.getSelected();                
                if(f.equals(new Boolean(true)))
                {
                    a.setOutros_acidentes_com_colaborador("n");                    
                }
            }
            else
            {
                a.setOutros_acidentes_com_colaborador("t");
            }            
        }
        
        boolean booAcidentesColaboradores = false;
        if(rbAcidentesColaboradoresY.getSelected() != null)
        {
            Boolean f = (Boolean) rbAcidentesColaboradoresY.getSelected();
            if(f.equals(new Boolean(true)))
            {
                a.setAcidentes_outros_colaboradores("y");
                booAcidentesColaboradores = true;
                if(txtNrAcidentesColaboradores.getText() != null)
                {
                    String nr_str = (String) txtNrAcidentesColaboradores.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_acidentes_outros_colaboradores(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }
                }
                
                if(txtNrRelatorioAcidentesColaboradores1.getText() != null)
                {
                    String nr_str = (String) txtNrRelatorioAcidentesColaboradores1.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_relatorio_acidente_outros_colaboradores1(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }                    
                }
                if(txtNrRelatorioAcidentesColaboradores2.getText() != null)
                {
                    String nr_str = (String) txtNrRelatorioAcidentesColaboradores2.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_relatorio_acidente_outros_colaboradores2(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }                    
                }  
                if(txtNrRelatorioAcidentesColaboradores3.getText() != null)
                {
                    String nr_str = (String) txtNrRelatorioAcidentesColaboradores3.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_relatorio_acidente_outros_colaboradores3(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }                    
                }                
                if(txtNrRelatorioAcidentesColaboradores4.getText() != null)
                {
                    String nr_str = (String) txtNrRelatorioAcidentesColaboradores4.getText();
                    if(nr_str.trim().length() > 0)
                    {
                        try
                        {
                            Integer nr = new Integer(Integer.parseInt(nr_str));
                            a.setNr_relatorio_acidente_outros_colaboradores4(nr);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }                        
                    }                    
                }                                                
                
            }
        }
        
        if(!booAcidentesColaboradores)
        {
            if(rbAcidentesColaboradoresN.getSelected() != null)            
            {
                Boolean f = (Boolean) rbAcidentesColaboradoresN.getSelected();                
                if(f.equals(new Boolean(true)))
                {
                    a.setAcidentes_outros_colaboradores("n");                    
                }
            }
            else
            {
                a.setAcidentes_outros_colaboradores("t");                    
            }                        
        }        
        
        return a;
    }    
    
    private ArrayList fillAnaliseRecomendacoesHs(AnaliseAcidente a)
    {
        System.out.println("FILL RECOMENDACOES");
        ArrayList list = new ArrayList();
        ListIterator iter = gridRecomendacoes.getChildren().listIterator();
        while(iter.hasNext())
        {
            HtmlPanelGrid grd = (HtmlPanelGrid)iter.next();
            TextArea ta = (TextArea) grd.getChildren().get(1);
            if(ta.getText() != null )
            {
                String txt = (String) ta.getText();
                if(txt.trim().length() > 0)
                {
                    Recomendacao r = new Recomendacao();
                    r.setAnalise_id(a.getId());
                    r.setRecomendacao(txt);
                    list.add(r);
                }
            }
        }        
        return list;
    }      
    
    private ArrayList fillAnaliseMedidasRh(AnaliseAcidente a)
    {
        ArrayList list = new ArrayList();
        ListIterator iter = gridMedidas.getChildren().listIterator();
        while(iter.hasNext())
        {
            HtmlPanelGrid grd = (HtmlPanelGrid)iter.next();
            TextArea ta = (TextArea) grd.getChildren().get(1);
            if(ta.getText() != null )
            {
                String txt = (String) ta.getText();
                if(txt.trim().length() > 0)
                {
                    Medida m = new Medida();
                    m.setAnalise_id(a.getId());
                    m.setMedida(txt);
                    list.add(m);
                }
            }
        }        
        return list;        
    }
    
    private AnaliseAcidente fillAnaliseFieldsRH2(AnaliseAcidente a)
    {
        return a;
    }        
    
    private AnaliseAcidente fillAnaliseFieldsMedico(AnaliseAcidente a)
    {
        a.setLesao_cabeca("n");        
        if(chkCabeca.getSelected() != null)
        {
            if(chkCabeca.getSelected().equals(new Boolean(true)))
            {
                a.setLesao_cabeca("y");
            }
        }
        
        a.setLesao_pescoco("n");        
        if(chkPescoco.getSelected() != null)
        {
            if(chkPescoco.getSelected().equals(new Boolean(true)))
            {
                a.setLesao_pescoco("y");
            }
        }        
        
        a.setLesao_tronco("n");        
        if(chkTronco.getSelected() != null)
        {
            if(chkTronco.getSelected().equals(new Boolean(true)))
            {
                a.setLesao_tronco("y");
            }
        }       
        
        a.setEspecif1("");
        a.setEspecif2("");        
        a.setEspecif3("");        
        a.setEspecif4("");   
        
        a.setLesao_membro_sup_dir("n");
        if(chkMembroSupDir.getSelected() != null)
        {
            if(chkMembroSupDir.getSelected().equals(new Boolean(true)))
            {
                a.setLesao_membro_sup_dir("y");
                if(txtEspecif1.getText() != null)
                {
                    a.setEspecif1((String) txtEspecif1.getText());                    
                }
            }
        }
        
        a.setLesao_membro_sup_esq("n");
        if(chkMembroSupEsq.getSelected() != null)
        {
            if(chkMembroSupEsq.getSelected().equals(new Boolean(true)))
            {
                a.setLesao_membro_sup_esq("y");
                if(txtEspecif2.getText() != null)
                {
                    a.setEspecif2((String) txtEspecif2.getText());                    
                }
            }
        }        
        
        a.setLesao_membro_inf_dir("n");
        if(chkMembroInfDir.getSelected() != null)
        {
            if(chkMembroInfDir.getSelected().equals(new Boolean(true)))
            {
                a.setLesao_membro_inf_dir("y");
                if(txtEspecif3.getText() != null)
                {
                    a.setEspecif3((String) txtEspecif3.getText());                    
                }
            }
        }        
        
        a.setLesao_membro_inf_esq("n");
        if(chkMembroInfEsq.getSelected() != null)
        {
            if(chkMembroInfEsq.getSelected().equals(new Boolean(true)))
            {
                a.setLesao_membro_inf_esq("y");
                if(txtEspecif4.getText() != null)
                {
                    a.setEspecif4((String) txtEspecif4.getText());                    
                }
            }
        }        
        
        a.setTipo_lesao("");
        if(txtTipoLesao.getText() != null)
        {
            a.setTipo_lesao((String) txtTipoLesao.getText());
        }
        
        a.setTipo_incapacidade("v");
        if(rbIncapacidadeNone.getSelected() != null)
        {
            if(rbIncapacidadeNone.getSelected().equals(new Boolean(true)))
            {
                a.setTipo_incapacidade("n");
            }
        }
        if(rbIncapacidadeTemp.getSelected() != null)
        {
            if(rbIncapacidadeTemp.getSelected().equals(new Boolean(true)))
            {
                a.setTipo_incapacidade("t");
            }
        } 
        if(rbIncapacidadePerm.getSelected() != null)
        {
            if(rbIncapacidadePerm.getSelected().equals(new Boolean(true)))
            {
                a.setTipo_incapacidade("p");
            }
        }         
        
        if(txtCoefIncapacidade.getText() != null)
        {
            String coef_str = txtCoefIncapacidade.getText().toString();
            int coef = Integer.parseInt(coef_str);
            a.setCoef_incapacidade(new Integer(coef));
        }
        
        DateFormat formatador = new SimpleDateFormat("yyyy-MM-dd");
        
        java.util.Date ddate  = (java.util.Date) calAvaliacaoIncap.getValue();
        try
        {
            String ddate_str = formatador.format(ddate);             
            java.sql.Date ddate_sql = new java.sql.Date(formatador.parse(ddate_str).getTime());                        
            a.setData_aval_incapacidade(ddate_sql);
        }
        catch(Exception ex)
        {
            a.setData_aval_incapacidade(null);                        
        }                    
        
        ddate  = (java.util.Date) calRevisaoIncap.getValue();

        try
        {
            String ddate_str = formatador.format(ddate);             
            java.sql.Date ddate_sql = new java.sql.Date(formatador.parse(ddate_str).getTime());                        
            a.setData_rev_incapacidade(ddate_sql);
        }
        catch(Exception ex)
        {
            a.setData_rev_incapacidade(null);                        
        }                    
        
        ddate  = (java.util.Date) calPeridoIncapDe.getValue();
        try
        {
            String ddate_str = formatador.format(ddate);             
            java.sql.Date ddate_sql = new java.sql.Date(formatador.parse(ddate_str).getTime());                        
            a.setPeriodo_incapacidade_de(ddate_sql);
        }
        catch(Exception ex)
        {
            a.setPeriodo_incapacidade_de(null);                        
        }                            
        
        ddate  = (java.util.Date) calPeriodoIncapA.getValue();
        try
        {
            String ddate_str = formatador.format(ddate);             
            java.sql.Date ddate_sql = new java.sql.Date(formatador.parse(ddate_str).getTime());                        
            a.setPeriodo_incapacidade_a(ddate_sql);
        }
        catch(Exception ex)
        {
            a.setPeriodo_incapacidade_a(null);                        
        }                                    
        
//        a.setImg_flexao("n");
//        if(chkImgFlexao.getSelected() != null)
//        {
//            if(chkImgFlexao.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_flexao("y");
//            }
//        }
//        
//        a.setImg_rot1("n");
//        if(chkImgRot1.getSelected() != null)
//        {
//            if(chkImgRot1.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_rot1("y");
//            }
//        }                                
//        
//        a.setImg_rot2("n");
//        if(chkImgRot2.getSelected() != null)
//        {
//            if(chkImgRot2.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_rot2("y");
//            }
//        }                        
//        
//        a.setImg_ext1("n");
//        if(chkImgExt1.getSelected() != null)
//        {
//            if(chkImgExt1.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ext1("y");
//            }
//        }
//
//        a.setImg_ext2("n");
//        if(chkImgExt2.getSelected() != null)
//        {
//            if(chkImgExt2.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ext2("y");
//            }
//        }  
//        
//        a.setImg_cab1("n");
//        if(chkImgCab1.getSelected() != null)
//        {
//            if(chkImgCab1.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_cab1("y");
//            }
//        }                
//        
//        a.setImg_cab2("n");
//        if(chkImgCab2.getSelected() != null)
//        {
//            if(chkImgCab2.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_cab2("y");
//            }
//        }        
//        
//        a.setImg_cab3("n");
//        if(chkImgCab3.getSelected() != null)
//        {
//            if(chkImgCab3.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_cab3("y");
//            }
//        }                
//        
//        a.setImg_cab4("n");
//        if(chkImgCab4.getSelected() != null)
//        {
//            if(chkImgCab4.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_cab4("y");
//            }
//        }                
//        
//        a.setImg_ma1("n");
//        if(chkImgMa1.getSelected() != null)
//        {
//            if(chkImgMa1.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma1("y");
//            }
//        }                        
//        
//        a.setImg_ma2("n");
//        if(chkImgMa2.getSelected() != null)
//        {
//            if(chkImgMa2.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma2("y");
//            }
//        }                
//        
//        a.setImg_ma3("n");
//        if(chkImgMa3.getSelected() != null)
//        {
//            if(chkImgMa3.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma3("y");
//            }
//        }                   
//        
//        a.setImg_ma4("n");
//        if(chkImgMa4.getSelected() != null)
//        {
//            if(chkImgMa4.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma4("y");
//            }
//        }                        
//        
//        a.setImg_ma5("n");
//        if(chkImgMa5.getSelected() != null)
//        {
//            if(chkImgMa5.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma5("y");
//            }
//        }                        
//        
//        a.setImg_ma6("n");
//        if(chkImgMa6.getSelected() != null)
//        {
//            if(chkImgMa6.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma6("y");
//            }
//        }                   
//        
//        a.setImg_ma7("n");
//        if(chkImgMa7.getSelected() != null)
//        {
//            if(chkImgMa7.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma7("y");
//            }
//        }                        
//        
//        a.setImg_ma8("n");
//        if(chkImgMa8.getSelected() != null)
//        {
//            if(chkImgMa8.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma8("y");
//            }
//        }                   
//        
//        a.setImg_ma9("n");
//        if(chkImgMa9.getSelected() != null)
//        {
//            if(chkImgMa9.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma9("y");
//            }
//        }                        
//        
//        a.setImg_ma10("n");
//        if(chkImgMa10.getSelected() != null)
//        {
//            if(chkImgMa10.getSelected().equals(new Boolean(true)))
//            {
//                a.setImg_ma10("y");
//            }
//        }                        
//        
//        a.setRestricao_carga(new Integer(0));
//        if(chkRestricaoCargas.getSelected()!= null)
//        {
//            if(chkRestricaoCargas.getSelected().equals(new Boolean(true)))
//            {
//                if(rbKgs2.getSelected() != null)
//                {
//                    if(rbKgs2.getSelected().equals(new Boolean(true)))
//                    {
//                        a.setRestricao_carga(new Integer(2));
//                    }
//                }
//                if(rbKgs5.getSelected() != null)
//                {
//                    if(rbKgs5.getSelected().equals(new Boolean(true)))
//                    {
//                        a.setRestricao_carga(new Integer(5));
//                    }
//                }                
//                if(rbKgs10.getSelected() != null)
//                {
//                    if(rbKgs10.getSelected().equals(new Boolean(true)))
//                    {
//                        a.setRestricao_carga(new Integer(10));
//                    }
//                }                
//                if(rbKgs15.getSelected() != null)
//                {
//                    if(rbKgs15.getSelected().equals(new Boolean(true)))
//                    {
//                        a.setRestricao_carga(new Integer(15));
//                    }
//                }    
//                
//                if(rbKgsOutro.getSelected() != null)
//                {
//                    if(rbKgsOutro.getSelected().equals(new Boolean(true)))
//                    {
//                        if(txtKgs.getText() != null)
//                        {
//                            String kgs_str = txtKgs.getText().toString();
//                            int kgs = Integer.parseInt(kgs_str);
//                            a.setRestricao_carga(new Integer(kgs));
//                        }
//                    }                    
//                }
//            }
//        }
//        
//        a.setRestricao_motricidade("n");
//        if(chkRestricaoMotricidade.getSelected() != null)
//        {
//            if(chkRestricaoMotricidade.getSelected().equals(new Boolean(true)))
//            {
//                a.setRestricao_motricidade("y");
//            }
//        }
//        
//        a.setRestricao_conducao("n");
//        if(chkRestricaoConducao.getSelected() != null)
//        {
//            if(chkRestricaoConducao.getSelected().equals(new Boolean(true)))
//            {
//                a.setRestricao_conducao("y");
//            }
//        }   
//        
//        a.setRestricao_vibracoes("n");
//        if(chkRestricaoVibracoes.getSelected() != null)
//        {
//            if(chkRestricaoVibracoes.getSelected().equals(new Boolean(true)))
//            {
//                a.setRestricao_vibracoes("y");
//            }
//        }        
//
//        a.setRestricao_outras("");
//        if(chkRestricaoOutras.getSelected() != null)
//        {
//            if(chkRestricaoOutras.getSelected().equals(new Boolean(true)))
//            {
//                if(txtRestricaoOutras.getText() != null)
//                {
//                    a.setRestricao_outras((String)txtRestricaoOutras.getText());
//                }
//            }
//        }
//        
//        a.setMed_observ("");
//        if(txtObservacoes.getText() != null)
//        {
//            a.setMed_observ( (String) txtObservacoes.getText() );
//        }
        
        return a;
    } 
    
    private AnaliseAcidente fillAnaliseFieldsConsolidacao(AnaliseAcidente a)
    {
        String nome_resp_consolidacao = getSessionBean1().getCurrentUser().getNome();
        a.setNome_resp_consolidacao(nome_resp_consolidacao);
        java.util.Date today =
                        new java.util.Date();
        java.sql.Date sqlToday =
                        new java.sql.Date(today.getTime());  
        a.setData_consolidacao(sqlToday);
        a.setAss_consolidacao("y");
        return a;
    }
    
    private AnaliseAcidente fillAnaliseAssinaturas(AnaliseAcidente a)
    {
        UtilizadoresDataProvider udp = new UtilizadoresDataProvider();  
        java.util.Date today = new java.util.Date();
        java.sql.Date sqlToday = new java.sql.Date(today.getTime());  
        int estado = a.getEstado().intValue();
        switch(estado)
        {
            case Global.ESTADO_ASSINATURA_SEG:
                //notifyNextSignature(new Integer(Global.ESTADO_ASSINATURA_RH)); 
                a.setData_assinatura_seg(sqlToday);        
                a.setAss_resp_seg("y");      
                a.setNome_resp_seg( getSessionBean1().getCurrentUser().getNome() );                
                break;
            case Global.ESTADO_ASSINATURA_RH:
                a.setData_assinatura_rh(sqlToday);                            
                a.setAss_resp_rh("y");
                a.setNome_resp_rh(getSessionBean1().getCurrentUser().getNome());                
                break;
        }
        
        return a;
    }
    
    private boolean validationDepartmentSectionOk()
    {
        Integer departmentId = (Integer) drpDepartamento.getSelected();
        if(departmentId.intValue()  == 0)
        {
            getSessionBean1().setMsg("Falta departamento!");
            return false;
        }
        Integer seccaoId = (Integer) drpSeccao.getSelected();        
        if(seccaoId.intValue()  == 0)
        {
            getSessionBean1().setMsg("Falta sec&ccedil;&atilde;o!");
            return false;
        }
        
        return true;
    }
    
    private boolean fieldsLenOk()
    {
        //System.out.println("VALIDATION GRAVAR OK");
        AnalisesDataProvider adp = new AnalisesDataProvider();
        HashMap meta = new HashMap();
        HashMap meta_ac = new HashMap();
        try
        {
            meta = adp.getMetaData("analises_acidentes");  
            meta_ac = adp.getMetaData("acidentados");
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            meta = null;
            meta_ac = null;
        }
        
        if(meta == null || meta_ac == null)
        {
            getSessionBean1().setMsg("Erro na aquisi&ccedil;&atilde;o da metadata!");
            return false;
        }

        int estado = 0;
        if(getSessionBean1().getCurrentAnalise() == null)  //null
        {
            estado = Global.ESTADO_SEG;
        }
        else
        {
            AnaliseAcidente a =  getSessionBean1().getCurrentAnalise();
            estado = a.getEstado().intValue();
        }        
        
        if(estado == Global.ESTADO_SEG)
        {
            if(txtAveriguador.getText() != null)
            {
                String averiguador = txtAveriguador.getText().toString();
                int len = ((Integer)meta.get("averiguador")).intValue();
                System.out.println("Averiguador : " + len);                
                if(averiguador.length() > len)
                {
                    getSessionBean1().setMsg("O campo Averiguador n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }            
            
            if(txtLocal.getText() != null)
            {
                String local = txtLocal.getText().toString();
                int len = ((Integer)meta.get("local_trabalho")).intValue();
                System.out.println("Local : " + len);                
                if(local.length() > len)
                {
                    getSessionBean1().setMsg("O campo Local n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }
            
            if(txtTarefa.getText() != null)
            {
                String tarefa = txtTarefa.getText().toString();
                int len = ((Integer)meta.get("tarefa")).intValue();
                System.out.println("Tarefa : " + len);                
                if(tarefa.length() > len)
                {
                    getSessionBean1().setMsg("O campo Tarefa n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                    
            
            if(txtSubstancias.getText() != null)
            {
                String substancias = txtSubstancias.getText().toString();
                int len = ((Integer)meta.get("substancias")).intValue();
                System.out.println("Substancias : " + len);                
                if(substancias.length() > len)
                {
                    getSessionBean1().setMsg("O campo Substancias n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                                
            
            if(txtTestemunhas.getText() != null)
            {
                String testemunhas = txtTestemunhas.getText().toString();
                int len = ((Integer)meta.get("testemunhas")).intValue();
                System.out.println("Testemunhas : " + len);                
                if(testemunhas.length() > len)
                {
                    getSessionBean1().setMsg("O campo Testemunhas n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                    
            
            if(txtDescricao.getText() != null)
            {
                String descricao = txtDescricao.getText().toString();
                int len = ((Integer)meta.get("descricao")).intValue();   
                System.out.println("Descricao : " + len);                                
                if(descricao.length() > len)
                {
                    getSessionBean1().setMsg("O campo Descri&ccedil;&atilde;o n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }            
            
            if(txtConclusoes.getText() != null)
            {
                String conclusoes = txtConclusoes.getText().toString();
                int len = ((Integer)meta.get("conclusoes")).intValue();                                
                System.out.println("Conclusoes : " + len);                                
                if(conclusoes.length() > len)
                {
                    getSessionBean1().setMsg("O campo Conclus&otilde;es n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                        
            
            if(txtAccoes.getText() != null)
            {
                String accoes = txtAccoes.getText().toString();
                int len = ((Integer)meta.get("accoes")).intValue();                                                
                System.out.println("Accoes : " + len);                                
                if(accoes.length() > len)
                {
                    getSessionBean1().setMsg("O campo Acc&otilde;es n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                    
            
            if(txtCondicoes.getText() != null)
            {
                String condicoes = txtCondicoes.getText().toString();
                int len = ((Integer)meta.get("condicoes")).intValue();                                                
                System.out.println("Condicoes : " + len);                                
                if(condicoes.length() > len)
                {
                    getSessionBean1().setMsg("O campo Condi&ccedil;&otilde;es n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            } 
            
            if(txtAveriguacaoObs.getText() != null)
            {
                String averiguacao_obs = txtAveriguacaoObs.getText().toString();
                int len = ((Integer)meta.get("averiguacao_obs")).intValue();
                System.out.println("Observacoes : " + len);                
                if(averiguacao_obs.length() > len)
                {
                    getSessionBean1().setMsg("O campo Observa&ccedil;&otilde;es n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }            
        }
        else if(estado == Global.ESTADO_RH1)
        {
            if(txtBI.getText() != null)
            {
                String bi = (String) txtBI.getText();
                int len = ((Integer)meta_ac.get("bilhete_identidade")).intValue();                                                
                System.out.println("BI : " + len);                                
                if(bi.length() > len)
                {
                    getSessionBean1().setMsg("Campo Bilhete Identidade n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
                try
                {
                    int bi_nr = Integer.parseInt(bi);
                }
                catch(Exception ex)
                {
                    getSessionBean1().setMsg("N&#186; do Bilhete de Identidade tem de ser num&eacute;rico!");
                    return false;                                            
                }
            }
            
            if(txtMorada.getText() != null)
            {
                String morada = txtMorada.getText().toString();
                int len = ((Integer)meta_ac.get("morada")).intValue();                                                
                System.out.println("Morada : " + len);                                
                if(morada.length() > len)
                {
                    getSessionBean1().setMsg("O campo Morada n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }   
            
            if(txtLocalidade.getText() != null)
            {
                String localidade = txtLocalidade.getText().toString();
                int len = ((Integer)meta_ac.get("localidade")).intValue();                                                
                System.out.println("Localidade : " + len);                                
                if(localidade.length() > len)
                {
                    getSessionBean1().setMsg("O campo Localidade n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                         
            
            if(txtContactoTelefonico.getText() != null)
            {
                String contacto_telefonico = txtContactoTelefonico.getText().toString();
                int len = ((Integer)meta_ac.get("contacto_telefonico")).intValue();                                                
                System.out.println("Contacto Telefonico : " + len);                                
                if(contacto_telefonico.length() > len)
                {
                    getSessionBean1().setMsg("O campo Contacto Telef&oacute;nico n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            } 
            
            if(txtNomeSuperior.getText() != null)
            {
                String nome_superior = txtNomeSuperior.getText().toString();
                int len = ((Integer)meta_ac.get("nome_superior_hierarquico")).intValue();                                                
                System.out.println("Nome Superior : " + len);                                
                if(nome_superior.length() > len)
                {
                    getSessionBean1().setMsg("O campo Nome do Superior Hier&aacute;rquico n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                     
            
            if(txtEmailSuperior.getText() != null)
            {
                String email_superior = txtEmailSuperior.getText().toString();
                int len = ((Integer)meta_ac.get("email_superior_hierarquico")).intValue();                                                
                System.out.println("Email Superior : " + len);                                
                if(email_superior.length() > len)
                {
                    getSessionBean1().setMsg("O campo Email do Superior Hier&aacute;rquico n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                                 
            
            if(txtEmailSuperior.getText() != null)
            {
                String email_superior = (String) txtEmailSuperior.getText();
                if(email_superior.trim().length() > 0)
                {
                    if(! utils.Utils.isValidEmail(email_superior))
                    {
                        getSessionBean1().setMsg("Email do superior hier&aacute;rquico inv&aacute;lido!");                                    
                        return false;
                    }
                }
            }  
            
            if(txtFormacaoSHSTNWhy.getText() != null)
            {
                String why = txtFormacaoSHSTNWhy.getText().toString();
                int len = ((Integer)meta.get("formacao_shst_nao_porque")).intValue();                                                
                System.out.println("Porque Nao Teve Formacao : " + len);                                
                if(why.length() > len)
                {
                    getSessionBean1().setMsg("O campo Porqu&ecirc; o Colaborador N&atilde;o Teve Forma&ccedil;&atilde;o n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                                             
        }
        else if(estado == Global.ESTADO_HS)
        {
            if(!checkRecomendacoesLen())
            {
                return false;
            }
        }
        else if(estado == Global.ESTADO_RH2)
        {
            if(!checkMedidasLen())
            {
                return false;
            } 
            
            if(txtEspecif1.getText() != null)
            {
                String especif = txtEspecif1.getText().toString();
                int len = ((Integer)meta.get("especif1")).intValue();                                                
                if(especif.length() > len)
                {
                    getSessionBean1().setMsg("O campo Especif&iacute;que n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                                 
            
            if(txtEspecif2.getText() != null)
            {
                String especif = txtEspecif2.getText().toString();
                int len = ((Integer)meta.get("especif2")).intValue();                                                
                if(especif.length() > len)
                {
                    getSessionBean1().setMsg("O campo Especif&iacute;que n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                         
            
            if(txtEspecif3.getText() != null)
            {
                String especif = txtEspecif3.getText().toString();
                int len = ((Integer)meta.get("especif3")).intValue();                                                
                if(especif.length() > len)
                {
                    getSessionBean1().setMsg("O campo Especif&iacute;que n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                         
            
            if(txtEspecif4.getText() != null)
            {
                String especif = txtEspecif4.getText().toString();
                int len = ((Integer)meta.get("especif4")).intValue();                                                
                if(especif.length() > len)
                {
                    getSessionBean1().setMsg("O campo Especif&iacute;que n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                                             
            
            if(txtTipoLesao.getText() != null)
            {
                String tipo_lesao = txtTipoLesao.getText().toString();
                int len = ((Integer)meta.get("tipo_lesao")).intValue();                                                
                System.out.println("Tipo Lesao : " + len);                                
                if(tipo_lesao.length() > len)
                {
                    getSessionBean1().setMsg("O campo Tipo Les&atilde;o n&atilde;o pode exceder " + len + " caracteres!");
                    return false;
                }
            }                                     
        }        
        
        return true;
    }
  
    private boolean validationOk()
    {
        
        if(getSessionBean1().isSubmetido() || getSessionBean1().isGravado())
        {
            return true;
        }
        if(getSessionBean1().getAcidentado() == null)
        {
            getSessionBean1().setMsg("N&atilde;o seleccionou trabalhador acidentado!");
            return false;
        }
        
        if(!fieldsLenOk())
        {
            return false;
        }
        
        int estado = 0;
        int estado_assinatura = 0;
        if(getSessionBean1().getCurrentAnalise() == null)  //null
        {
            estado = Global.ESTADO_SEG;
        }
        else
        {
            AnaliseAcidente a =  getSessionBean1().getCurrentAnalise();
            estado = a.getEstado().intValue();
            estado_assinatura = a.getEstado_assinatura().intValue();
        }
        
        if(estado == Global.ESTADO_SEG)
        {
            if(txtAveriguador.getText() == null)
            {
                getSessionBean1().setMsg("Falta averiguador!");
                return false;
            }
            else
            {
                String averiguador = (String) txtAveriguador.getText();
                if(averiguador.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta averiguador!");
                    return false;
                }

            }
            
            if(drpHours.getSelected() == null || drpMinutes.getSelected() == null)
            {
                getSessionBean1().setMsg("Falta hora acidente!");
                return false;
            }
            else
            {
                Integer h = (Integer) drpHours.getSelected();
                Integer m = (Integer) drpMinutes.getSelected();
                if(h.intValue() == -1 || m.intValue() == -1)
                {
                    getSessionBean1().setMsg("Falta hora acidente!");
                    return false;                    
                }
                
            }
            
            if(txtHorasTurno.getText() != null)
            {
                String horas_turno = txtHorasTurno.getText().toString();
                if(horas_turno.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta n&#186; horas trabalhadas no turno!");
                    return false;                    
                }
                else
                {
                    try
                    {
                        int nr = Integer.parseInt(horas_turno);                
                        if(nr > 9)
                        {
                            getSessionBean1().setMsg("As horas turno devem ser entre 0 e 9!");                                    
                            return false;
                        }
                    }
                    catch(Exception ex)
                    {
                        getSessionBean1().setMsg("As horas turno devem ser um valor num&eacute;rico!");                
                        return false;
                    }                    
                }
            }                 
            else
            {
                getSessionBean1().setMsg("Falta n&#186; horas trabalhadas no turno!");
                return false;
            }
            
           
            if(drpDepartamento.getSelected() == null)
            {
                getSessionBean1().setMsg("Falta departamento!");
                return false;
            }
            else
            {
                Integer d = (Integer) drpDepartamento.getSelected();
                if(d.intValue() == 0)
                {
                    getSessionBean1().setMsg("Falta departamento!");
                    return false;                    
                }
            }                        
            
            if(drpSeccao.getSelected() == null)
            {
                getSessionBean1().setMsg("Falta sec&ccedil;&atilde;o!");
                return false;
            }
            else
            {
                Integer s = (Integer) drpSeccao.getSelected();
                if(s.intValue() == 0)
                {
                    getSessionBean1().setMsg("Falta sec&ccedil;&atilde;o!");
                    return false;                    
                }
            }            
            
            if(txtLocal.getText() == null)
            {
                getSessionBean1().setMsg("Falta local espec&iacute;fico!");
                return false;                
            }
            else
            {
                String local = (String) txtLocal.getText();
                if(local.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta local espec&iacute;fico!");
                    return false;                                    
                }
            }
            
            if(txtTarefa.getText() == null)
            {
                getSessionBean1().setMsg("Falta tarefa!");
                return false;
            }
            else
            {
                String tarefa = (String) txtTarefa.getText();
                if(tarefa.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta tarefa!");
                    return false;                    
                }
            }
            
            if(txtSubstancias.getText() == null)
            {
                getSessionBean1().setMsg("Falta subst&acirc;ncias!");
                return false;
            }
            else
            {
                String substancias = (String) txtSubstancias.getText();
                if(substancias.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta subst&acirc;ncias!");
                    return false;                    
                }
            }
            
            if(txtCondicoes.getText() == null)
            {
                getSessionBean1().setMsg("Falta condi&ccedil;&otilde;es!");
                return false;
            }
            else
            {
                String condicoes = (String) txtCondicoes.getText();
                if(condicoes.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta condi&ccedil;&otilde;es!");
                    return false;                    
                }
            }
            
            if(txtTestemunhas.getText() == null)
            {
                getSessionBean1().setMsg("Falta testemunhas!");
                return false;                
            }
            else
            {
                String testemunhas = (String) txtTestemunhas.getText();
                if(testemunhas.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta testemunhas!");
                    return false;                                    
                }
            }
            
            if(drpCausas.getSelected() == null)
            {
                getSessionBean1().setMsg("Falta causa do acidente!");
                return false;
            }
            else
            {
                Integer c = (Integer) drpCausas.getSelected();
                if(c.intValue() == 0)
                {
                    getSessionBean1().setMsg("Falta causa do acidente!");
                    return false;                    
                }
            }
            
            if(txtDescricao.getText() == null)
            {
                getSessionBean1().setMsg("Falta descri&ccedil;&atilde;o do acidente!");
                return false;
            }
            else
            {
                String descricao = (String) txtDescricao.getText();
                if(descricao.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta descri&ccedil;&atilde;o do acidente!");
                    return false;                    
                }
            }
            
            if(txtConclusoes.getText() == null)
            {
                getSessionBean1().setMsg("Falta conclus&otilde;es!");
                return false;
            }
            else
            {
                String conclusoes = (String) txtConclusoes.getText();
                if(conclusoes.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta conclus&otilde;es!");
                    return false;                    
                }
            }
            
            if(txtAccoes.getText() == null)
            {
                getSessionBean1().setMsg("Falta ac&ccedil;&otilde;es!");
                return false;
            }
            else
            {
                String accoes = (String) txtAccoes.getText();
                if(accoes.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta ac&ccedil;&otilde;es!");
                    return false;                    
                }
            }
            
        }
        
        
        if(estado == Global.ESTADO_RH1)
        {
            
            if(txtBI.getText() == null)
            {
                getSessionBean1().setMsg("Falta N&#186; Bilhete de Identidade!");
                return false;
            }
            else
            {
                String bi = (String) txtBI.getText();
                if(bi.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta N&#186; Bilhete de Identidade!");
                    return false;                    
                }
                else
                {
                    try
                    {
                        int bi_nr = Integer.parseInt(bi);
                    }
                    catch(Exception ex)
                    {
                        getSessionBean1().setMsg("N&#186; do Bilhete de Identidade tem de ser num&eacute;rico!");
                        return false;                                            
                    }
                }
            }
            
            if(txtMorada.getText() == null)
            {
                getSessionBean1().setMsg("Falta morada!");
                return false;
            }
            else
            {
                String morada = (String) txtMorada.getText();
                if(morada.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta morada!");
                    return false;
                }
            }

            String cod_postal1 = "";
            String cod_postal2 = "";                        
            if(txtCodPostal1.getText() == null || txtCodPostal2.getText() == null)
            {
                getSessionBean1().setMsg("Falta c&oacute;digo postal!");
                return false;                
            }
            else
            {
                cod_postal1 = (String) txtCodPostal1.getText();                
                cod_postal2 = (String) txtCodPostal2.getText();
                
                if(cod_postal1.trim().length() == 0 || cod_postal2.trim().length() == 0)
                {
                    getSessionBean1().setMsg("Falta c&oacute;digo postal!");
                    return false;                
                }
            }
            
            if(txtCodPostal1.getText() != null)
            {
                if(cod_postal1.trim().length() > 0)
                {
                    try
                    {
                        int nr = Integer.parseInt(cod_postal1);                
                        if(nr < 1000  || nr > 9999)
                        {
                            getSessionBean1().setMsg("O formato do c&oacute;digo postal &eacute : '9999-999'");                                    
                            return false;
                        }
                    }
                    catch(Exception ex)
                    {
                        getSessionBean1().setMsg("O c&oacute;digo postal tem de ser um valor num&eacute;rico!");                
                        return false;
                    }                    
                }
            }
            
            if(txtCodPostal2.getText() != null)
            {
                if(cod_postal2.trim().length() > 0)
                {
                    if(cod_postal1.trim().length() == 0)
                    {
                        getSessionBean1().setMsg("O formato do c&oacute;digo postal &eacute : '9999-999'");                                    
                        return false;                        
                    }
                    try
                    {
                        int nr = Integer.parseInt(cod_postal2);                
                        if(cod_postal2.length() > 3 )
                        {
                            getSessionBean1().setMsg("O formato do c&oacute;digo postal &eacute : '9999-999'");                                    
                            return false;
                        }
                    }
                    catch(Exception ex)
                    {
                        getSessionBean1().setMsg("O c&oacute;digo postal de ser um valor num&eacute;rico!");                
                        return false;
                    }                    
                }
                
                if(txtLocalidade.getText() == null)
                {
                    getSessionBean1().setMsg("Falta localidade!");
                    return false;
                }
                else
                {
                    String localidade = (String) txtLocalidade.getText();
                    if(localidade.trim().length() == 0)
                    {
                        getSessionBean1().setMsg("Falta localidade!");
                        return false;
                    }
                }
                
                if(txtContactoTelefonico.getText() == null)
                {
                    getSessionBean1().setMsg("Falta contacto telef&oacute;nico!");
                    return false;
                }
                else
                {
                    String contacto_telefonico = (String) txtContactoTelefonico.getText();
                    if(contacto_telefonico.trim().length() == 0)
                    {
                        getSessionBean1().setMsg("Falta contacto telef&oacute;nico!");
                        return false;
                    }
                }
                
                if(rbTurnoManha.getSelected() == null && rbTurnoTarde.getSelected() == null && rbTurnoNoite.getSelected() == null )
                {
                    getSessionBean1().setMsg("Falta turno de trabalho!");
                    return false;                    
                }
                
                if(txtNomeSuperior.getText() == null)
                {
                    getSessionBean1().setMsg("Falta nome do superior hier&aacute;rquico!");
                    return false;
                }
                else
                {
                    String nome_superior = (String) txtNomeSuperior.getText();
                    if(nome_superior.trim().length() == 0)
                    {
                        getSessionBean1().setMsg("Falta nome do superior hier&aacute;rquico!");
                        return false;                        
                    }
                }
                
                if(txtEmailSuperior.getText() != null)
                {
                    String email_superior = (String) txtEmailSuperior.getText();
                    if(email_superior.trim().length() > 0)
                    {
                        if(! utils.Utils.isValidEmail(email_superior))
                        {
                            getSessionBean1().setMsg("Email do superior hier&aacute;rquico inv&aacute;lido!");                                    
                            return false;
                        }
                    }
                    else
                    {
                        getSessionBean1().setMsg("Falta email do superior hier&aacute;rquico!");
                        return false;
                    }
                }
                else
                {
                    getSessionBean1().setMsg("Falta email do superior hier&aacute;rquico!");
                    return false;                    
                }
            }            
            
            if(estado == Global.ESTADO_RH1)
            {
                
                if(rbFormacaoSHSTY.getSelected() == null && rbFormacaoSHSTN.getSelected() == null)
                {
                    getSessionBean1().setMsg("Falta indicar se o colaborador teve forma&ccedil;&atilde;o em SHST!");
                    return false;
                }
                else
                {
                    if(rbFormacaoSHSTY.getSelected() != null)
                    {
                        if(rbFormacaoSHSTY.getSelected().equals(new Boolean(false)))
                        {
                            if(rbFormacaoSHSTN.getSelected() != null)
                            {
                                if(rbFormacaoSHSTN.getSelected().equals(new Boolean(false)))
                                {
                                    getSessionBean1().setMsg("Falta indicar se o colaborador teve forma&ccedil;&atilde;o em SHST!");
                                    return false;                        
                                }
                            }
                        }
                    }
                }
                
                if(rbFormacaoSHSTN.getSelected() != null)                
                {
                    if(rbFormacaoSHSTN.getSelected().equals(new Boolean(true)))
                    {
                        if(txtFormacaoSHSTNWhy.getText() == null)
                        {
                            getSessionBean1().setMsg("Falta indicar a raz&atilde;o porque o colaborador n&atilde;o teve forma&ccedil;&atilde;o em SHST!");
                            return false;                        
                        }
                        else
                        {
                            String why = (String) txtFormacaoSHSTNWhy.getText();
                            if(why.trim().length() == 0)
                            {
                                getSessionBean1().setMsg("Falta indicar a raz&atilde;o porque o colaborador n&atilde;o teve forma&ccedil;&atilde;o em SHST!");
                                return false;                                                    
                            }
                        }
                    }
                    
                }
                
                if(rbAcidentesColaboradorY.getSelected() == null && rbAcidentesColaboradorN.getSelected() == null)
                {
                    getSessionBean1().setMsg("Falta indicar se o colaborador teve outras ocorr&ecirc;ncias, ou n&atilde;o!");
                    return false;                    
                }
                else
                {
                    if(rbAcidentesColaboradorY.getSelected() != null)
                    {
                        if(rbAcidentesColaboradorY.getSelected().equals(new Boolean(false)))                        
                        {
                            if(rbAcidentesColaboradorN.getSelected() != null)                            
                            {
                                if(rbAcidentesColaboradorN.getSelected().equals(new Boolean(false)))                                                        
                                {
                                    getSessionBean1().setMsg("Falta indicar se o colaborador teve outras ocorr&ecirc;ncias, ou n&atilde;o!");
                                    return false;                                                                                
                                }
                            }
                        }
                    }
                }
                
                if(rbAcidentesColaboradorY.getSelected() != null)                
                {

                    if(rbAcidentesColaboradorY.getSelected().equals(new Boolean(true)))
                    {
                        if(txtNrAcidentesColaborador.getText() != null)
                        {
                            String nr_str = txtNrAcidentesColaborador.getText().toString();
                            if(nr_str.trim().length() > 0)
                            {
                                try
                                {
                                    int nr = Integer.parseInt(nr_str);                
                                }
                                catch(Exception ex)
                                {
                                    getSessionBean1().setMsg("O &#186; de acidentes do colaborador deve ser um valor num&eacute;rico!");                
                                    return false;
                                }                    
                            }
                            else
                            {
                                getSessionBean1().setMsg("Falta indicar o &#186; de ocorr&ecirc;ncias do colaborador!");
                                return false;                            
                            }
                        }
                        else
                        {
                            getSessionBean1().setMsg("Falta indicar o &#186; de ocorr&ecirc;ncias do colaborador!");
                            return false;
                        }

                        if(
                           txtNrRelatorioAcidentesColaborador1.getText() == null && 
                           txtNrRelatorioAcidentesColaborador2.getText() == null &&                              
                           txtNrRelatorioAcidentesColaborador3.getText() == null &&                             
                           txtNrRelatorioAcidentesColaborador1.getText() == null                             
                        )
                        {
                            getSessionBean1().setMsg("Falta indicar o(s) &#186;(s) do(s) relat&oacute;rio(s) de acidente do colaborador!");
                            return false;
                        }
                        else
                        {
                            String nr_relatorio1 = "";
                            String nr_relatorio2 = "";                        
                            String nr_relatorio3 = "";                        
                            String nr_relatorio4 = "";                        
                            if(txtNrRelatorioAcidentesColaborador1.getText() != null)
                            {
                                nr_relatorio1 = (String) txtNrRelatorioAcidentesColaborador1.getText();                            
                            }
                            if(txtNrRelatorioAcidentesColaborador2.getText() != null)
                            {
                                nr_relatorio2 = (String) txtNrRelatorioAcidentesColaborador2.getText();                            
                            }
                            if(txtNrRelatorioAcidentesColaborador3.getText() != null)
                            {
                                nr_relatorio3 = (String) txtNrRelatorioAcidentesColaborador3.getText();                            
                            }                        
                            if(txtNrRelatorioAcidentesColaborador4.getText() != null)
                            {
                                nr_relatorio4 = (String) txtNrRelatorioAcidentesColaborador4.getText();                            
                            }   

                            if(nr_relatorio1.trim().length() == 0 && nr_relatorio2.trim().length() == 0 && nr_relatorio3.trim().length() == 0 && nr_relatorio4.trim().length() == 0)
                            {
                                getSessionBean1().setMsg("Falta indicar o(s) &#186;(s) do(s) relat&oacute;rio(s) de acidente do colaborador!");
                                return false;                            
                            }
                        }
                    }//                    
                    
                }

                
                
                if(rbAcidentesColaboradoresY.getSelected() == null && rbAcidentesColaboradoresN.getSelected() == null)
                {
                    getSessionBean1().setMsg("Falta indicar se houve outras ocorr&ecirc;ncias com outros colaboradores!");
                    return false;                    
                }
                else
                {
                    if(rbAcidentesColaboradoresY.getSelected() != null)
                    {
                        if(rbAcidentesColaboradoresY.getSelected().equals(new Boolean(false)))                        
                        {
                            if(rbAcidentesColaboradoresN.getSelected() != null)
                            {
                                if(rbAcidentesColaboradoresN.getSelected().equals(new Boolean(false)))                                
                                {
                                    getSessionBean1().setMsg("Falta indicar se houve outras ocorr&ecirc;ncias com outros colaboradores!");
                                    return false;                                                                                
                                }
                            }
                        }
                    }
                }
                
                if(rbAcidentesColaboradoresY.getSelected() != null)                
                {

                    if(rbAcidentesColaboradoresY.getSelected().equals(new Boolean(true)))
                    {
                        if(txtNrAcidentesColaboradores.getText() != null)
                        {
                            String nr_str = txtNrAcidentesColaboradores.getText().toString();
                            if(nr_str.trim().length() > 0)
                            {
                                try
                                {
                                    int nr = Integer.parseInt(nr_str);                
                                }
                                catch(Exception ex)
                                {
                                    getSessionBean1().setMsg("O &#186; de acidentes dos colaboradores deve ser um valor num&eacute;rico!");                
                                    return false;
                                }                                                
                            }
                            else
                            {
                                getSessionBean1().setMsg("Falta indicar o &#186; de ocorr&ecirc;ncias com outros colaboradores!");
                                return false;                            
                            }
                        }                                    
                        else
                        {
                            getSessionBean1().setMsg("Falta indicar o &#186; de ocorr&ecirc;ncias com outros colaboradores!");
                            return false;                                                    
                        }

                        if(
                           txtNrRelatorioAcidentesColaboradores1.getText() == null && 
                           txtNrRelatorioAcidentesColaboradores2.getText() == null &&                              
                           txtNrRelatorioAcidentesColaboradores3.getText() == null &&                             
                           txtNrRelatorioAcidentesColaboradores1.getText() == null                             
                        )
                        {
                            getSessionBean1().setMsg("Falta indicar o(s) &#186;(s) do(s) relat&oacute;rio(s) de acidente com outros colaboradores!");
                            return false;
                        }
                        else
                        {
                            String nr_relatorio1 = "";
                            String nr_relatorio2 = "";                        
                            String nr_relatorio3 = "";                        
                            String nr_relatorio4 = "";                        
                            if(txtNrRelatorioAcidentesColaboradores1.getText() != null)
                            {
                                nr_relatorio1 = (String) txtNrRelatorioAcidentesColaboradores1.getText();                            
                            }
                            if(txtNrRelatorioAcidentesColaboradores2.getText() != null)
                            {
                                nr_relatorio2 = (String) txtNrRelatorioAcidentesColaboradores2.getText();                            
                            }
                            if(txtNrRelatorioAcidentesColaboradores3.getText() != null)
                            {
                                nr_relatorio3 = (String) txtNrRelatorioAcidentesColaboradores3.getText();                            
                            }                        
                            if(txtNrRelatorioAcidentesColaboradores4.getText() != null)
                            {
                                nr_relatorio4 = (String) txtNrRelatorioAcidentesColaboradores4.getText();                            
                            }   

                            if(nr_relatorio1.trim().length() == 0 && nr_relatorio2.trim().length() == 0 && nr_relatorio3.trim().length() == 0 && nr_relatorio4.trim().length() == 0)
                            {
                                getSessionBean1().setMsg("Falta indicar o(s) &#186;(s) do(s) relat&oacute;rio(s) de acidente com outros colaboradores!");
                                return false;                            
                            }
                        }                    
                    }//                    
                    
                }

            }
        }
        else if(estado == Global.ESTADO_HS) //recomendacoes
        {
            if(isRecomendacoesEmpty())
            {
                getSessionBean1().setMsg("Tem de preencher pelo menos uma recomenda&ccedil;&atilde;o!");
                return false;
            }
        }
        else if(estado == Global.ESTADO_RH2) //medidas
        {
            if(isMedidasEmpty())
            {
                getSessionBean1().setMsg("Tem de preencher pelo menos uma medida!");
                return false;
            }            
//        }
//        //else if(estado == Global.ESTADO_MEDICINA)
//        else if(estado == Global.ESTADO_RH2)
//        {
            if(rbIncapacidadeNone.getSelected() == null && rbIncapacidadeTemp.getSelected() == null && rbIncapacidadePerm.getSelected() == null)
            {
                getSessionBean1().setMsg("Falta indicar o tipo de incapacidade!");
                return false;
            }
            else
            {
                if(rbIncapacidadeNone.getSelected() != null)
                {
                    if(rbIncapacidadeNone.getSelected().equals(new Boolean(false)))
                    {
                        if(rbIncapacidadeTemp.getSelected() != null)                        
                        {
                            if(rbIncapacidadeTemp.getSelected().equals(new Boolean(false)))                            
                            {
                                if(rbIncapacidadePerm.getSelected() != null)                                                        
                                {
                                    if(rbIncapacidadePerm.getSelected().equals(new Boolean(false)))                                                                
                                    {
                                        getSessionBean1().setMsg("Falta indicar o tipo de incapacidade!");
                                        return false;                                                            
                                    }
                                }
                            }
                        }
                    }
                }
            }
                
            if(txtCoefIncapacidade.getText() != null)
            {
                String coef_str = txtCoefIncapacidade.getText().toString();
                if(coef_str.trim().length() > 0)
                {
                    try
                    {
                        int nr = Integer.parseInt(coef_str);                
                    }
                    catch(Exception ex)
                    {
                        getSessionBean1().setMsg("O coeficiente de incapacidade deve ser um valor num&eacute;rico!");                
                        return false;
                    }                                    
                }
                else
                {
                    getSessionBean1().setMsg("Falta coeficiente de incapacidade!");
                    return false;                    
                }
            }
            else
            {
                getSessionBean1().setMsg("Falta coeficiente de incapacidade!");
                return false;
            }
            
            if(chkRestricaoCargas.getSelected() != null)
            {
                Boolean b = (Boolean) chkRestricaoCargas.getSelected();
                if(b.equals(new Boolean(true)))
                {
                    if(txtKgs.getText() != null)
                    {
                        String kgs_str = txtKgs.getText().toString();
                        try
                        {
                            int nr = Integer.parseInt(kgs_str);                
                        }
                        catch(Exception ex)
                        {
                            getSessionBean1().setMsg("O valor de kgs deve ser um valor num&eacute;rico!");                
                            return false;
                        }                                        
                    }
                }
            }
        }
        else if(estado == Global.ESTADO_CONSOLIDACAO) 
        {
            if(chkVerHs.getSelected() == null)
            {
                getSessionBean1().setMsg("Falta assinatura!");  
                return false;                                                    
            }
            else if(chkVerHs.getSelected().equals(new Boolean(false)))
            {
                getSessionBean1().setMsg("Falta assinatura!");  
                return false;                                                                                
            }
        }
        else if(estado == Global.ESTADO_ASSINATURA_SEG)
        {
            if(chkVerRespSeg.getSelected() == null)
            {
                getSessionBean1().setMsg("Falta assinatura!");  
                return false;                                                    
            }
            else if(chkVerRespSeg.getSelected().equals(new Boolean(false)))
            {
                getSessionBean1().setMsg("Falta assinatura!");  
                return false;                                                                                
            }
        }    
        else if(estado == Global.ESTADO_ASSINATURA_RH)
        {
            if(chkVerRespRh.getSelected() == null)
            {
                getSessionBean1().setMsg("Falta assinatura!");  
                return false;                                                    
            }
            else if(chkVerRespRh.getSelected().equals(new Boolean(false)))
            {
                getSessionBean1().setMsg("Falta assinatura!");  
                return false;                                                                                
            }
        }    
        

        return true;
    }
    
    private void createImagesFolder(AnaliseAcidente a)
    //private void createImagesFolder(String folderName)
    {
        String folderName = a.getAnalise_nr().substring(0,2) + a.getAnalise_nr().substring(3);
        
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
//         String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName);                
         String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName;                        
         try
         {
//            String imageFileFolderTmp = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin());        
            String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin();                    
            File f = new File(imageFileFolderTmp);
            if( f.exists() )
            {
                File folder = new File(imageFileFolder);
                folder.mkdir();   

                File files[] = f.listFiles();

                for(int i=0;i<files.length;i++)
                {
                    if(files[i].isFile())       
                    {
                        // Move file to new directory

                        boolean success = files[i].renameTo(new File(folder, files[i].getName()));
                    }
                }

                //delete tmp folder
                f.delete();                
            }

         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }
        
    }
    
    //private void updateImagesFolder(String folderName)
    private void updateImagesFolder(AnaliseAcidente a)
    {
        String folderName = a.getAnalise_nr().substring(0,2) + a.getAnalise_nr().substring(3);        
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
         try
         {
             //checks if there are images in tmp
//            String imageFileFolderTmp = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin());        
            String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin();                     
            File ftmp = new File(imageFileFolderTmp);
            if( ftmp.exists() )
            {
                 //if so, checks if there is already a image folder
//                 String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName);                                
                 String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName;                                                
                 File fimages = new File(imageFileFolder);
                 if(! fimages.exists())
                 {
                     // create image folder
                     fimages.mkdir();
                 }
                 //copy images onto it
                File files[] = ftmp.listFiles();

                for(int i=0;i<files.length;i++)
                {
                    if(files[i].isFile())       
                    {
                        // Move file to new directory
                        boolean success = files[i].renameTo(new File(fimages, files[i].getName()));
                    }
                }  
                //delete tmp folder
                ftmp.delete();                                
            }
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }
    }
    
    private void savePageState()
    {
        AnaliseAcidenteTrabalhoState a = new AnaliseAcidenteTrabalhoState();
        a.setHeader_nr(stHeaderNr.getText());
        a.setHeader_date(stHeaderDate.getText());
        if(getSessionBean1().getCurrentAnalise() == null)        
        {
            a.setEstado(Global.ESTADO_SEG);
        }
        else
        {
            a.setEstado(getSessionBean1().getCurrentAnalise().getEstado().intValue());
        }
        a.setEmpresa(txtEmpresa.getText());
        a.setHoras_turno(txtHorasTurno.getText());
        
        a.setAveriguador(txtAveriguador.getText());
        a.setData_nascimento(stDataNascimento.getText());
        a.setData_admissao(stDataAdmissao1.getText());
        a.setData_acidente(calDataOcorrencia.getValue());
        a.setBi(stBI.getText());
        a.setMorada(stMorada.getText());
        a.setContacto_telefonico(stContactoTelefonico.getText());
        a.setFuncao(stFuncao1.getText());
        a.setTurno(stTurno.getText());
        
        //////a.setData_acidente(stDataAcidente.getText());
//        a.setBi(txtBI.getText());
//        a.setMorada(txtMorada.getText());
//        a.setCod_postal1(txtCodPostal1.getText());
//        a.setCod_postal2(txtCodPostal2.getText());        
//        a.setLocalidade(txtLocalidade.getText());
//        a.setContacto_telefonico(txtContactoTelefonico.getText());
//        a.setTurno("m");        
//        if(rbTurnoManha.getSelected() != null)
//        {
//            Boolean b = (Boolean) rbTurnoManha.getSelected();
//            if(b.equals(new Boolean(true)))
//            {
//                a.setTurno("m");
//            }
//        }
//
//        if(rbTurnoTarde.getSelected() != null)
//        {
//            Boolean b = (Boolean) rbTurnoTarde.getSelected();
//            if(b.equals(new Boolean(true)))
//            {
//                a.setTurno("t");
//            }
//        }        
//        
//        if(rbTurnoNoite.getSelected() != null)
//        {
//            Boolean b = (Boolean) rbTurnoNoite.getSelected();
//            if(b.equals(new Boolean(true)))
//            {
//                a.setTurno("n");
//            }
//        }        
        Integer hours = (Integer) drpHours.getSelected();
        Integer minutes = (Integer) drpMinutes.getSelected();        
        a.setHours(hours);
        a.setMinutes(minutes);
        a.setLocal_trabalho(txtLocal.getText());
        ////a.setSeccao(txtSeccao.getText());
        a.setSubstancias(txtSubstancias.getText());
        a.setTarefa(txtTarefa.getText());
        a.setEstabelecimento(txtEstabelecimento.getText());
        a.setTrabalhador(txtTrabalhador.getText());
        a.setData_nascimento(txtDataNascimento.getText());
        
//        a.setSuperior_hierarquico(txtSuperior.getText());
        a.setCondicoes(txtCondicoes.getText());
        a.setTestemunhas(txtTestemunhas.getText());
//        a.setCausas(txtCausas.getText());
        a.setCausas(drpCausas.getSelected());
        a.setDescricao(txtDescricao.getText());
        a.setConclusoes(txtConclusoes.getText());
        a.setAccoes(txtAccoes.getText());
        
        a.setAveriguacao_posterior("n");        
        if(chkAveriguacaoPosterior.getSelected() != null)
        {
            if(chkAveriguacaoPosterior.getSelected().equals(new Boolean(true)))
            {
                a.setAveriguacao_posterior("y");
            }
        }
        a.setAveriguacao_obs(txtAveriguacaoObs.getText());
        
        if(getSessionBean1().getCurrentAnalise() != null)
        {
            if(getSessionBean1().getCurrentAnalise().getEstado().intValue() == Global.ESTADO_RH1)
            {
                
                a.setFormacao_shst("n");            
                if(rbFormacaoSHSTY.getSelected() != null)
                {
                    Boolean b = (Boolean) rbFormacaoSHSTY.getSelected();
                    if(b.equals(new Boolean(true)))
                    {
                        a.setFormacao_shst("y");
                    }
                }
                if(rbFormacaoSHSTN.getSelected() != null)
                {
                    Boolean b = (Boolean) rbFormacaoSHSTN.getSelected();
                    if(b.equals(new Boolean(true)))
                    {
                        a.setFormacao_shst("n");
                    }
                } 

                a.setFormacao_shsht_n_why(txtFormacaoSHSTNWhy.getText());

                a.setAcidentes_colaborador("n");
                if(rbAcidentesColaboradorY.getSelected() != null)
                {
                    Boolean b = (Boolean) rbAcidentesColaboradorY.getSelected();
                    if(b.equals(new Boolean(true)))
                    {
                        a.setAcidentes_colaborador("y");
                    }
                }

                if(rbAcidentesColaboradorN.getSelected() != null)
                {
                    Boolean b = (Boolean) rbAcidentesColaboradorN.getSelected();
                    if(b.equals(new Boolean(true)))
                    {
                        a.setAcidentes_colaborador("n");
                    }
                }            

                a.setNr_acidentes_colaborador(txtNrAcidentesColaborador.getText());
                a.setNr_relatorio_acidentes_colaborador_1(txtNrRelatorioAcidentesColaborador1.getText());
                a.setNr_relatorio_acidentes_colaborador_2(txtNrRelatorioAcidentesColaborador2.getText());                
                a.setNr_relatorio_acidentes_colaborador_3(txtNrRelatorioAcidentesColaborador3.getText());                
                a.setNr_relatorio_acidentes_colaborador_4(txtNrRelatorioAcidentesColaborador4.getText());                

                a.setAcidentes_colaboradores("n");
                if(rbAcidentesColaboradoresY.getSelected() != null)
                {
                    Boolean b = (Boolean) rbAcidentesColaboradoresY.getSelected();
                    if(b.equals(new Boolean(true)))
                    {
                        a.setAcidentes_colaboradores("y");
                    }
                }

                if(rbAcidentesColaboradoresN.getSelected() != null)
                {
                    Boolean b = (Boolean) rbAcidentesColaboradoresN.getSelected();
                    if(b.equals(new Boolean(true)))
                    {
                        a.setAcidentes_colaboradores("n");
                    }
                }            

                a.setNr_acidentes_colaboradores(txtNrAcidentesColaboradores.getText());                            
                a.setNr_relatorio_acidentes_colaboradores_1(txtNrRelatorioAcidentesColaboradores1.getText());
                a.setNr_relatorio_acidentes_colaboradores_2(txtNrRelatorioAcidentesColaboradores2.getText());                
                a.setNr_relatorio_acidentes_colaboradores_3(txtNrRelatorioAcidentesColaboradores3.getText());                
                a.setNr_relatorio_acidentes_colaboradores_4(txtNrRelatorioAcidentesColaboradores4.getText());                                

            }

        }
        
        getSessionBean1().setAnalise_acidente_trabalho_state(a);
    }
    
    private void restorePageState()
    {
        AnaliseAcidenteTrabalhoState a = getSessionBean1().getAnalise_acidente_trabalho_state();
       butCorrecao.setRendered(false);
       butGravar.setText("Gravar");
       butImprimir.setRendered(false);
       getSessionBean1().setIeBug(false);  //THIS MUST BE SEEN !!!!!
        if(a.getEstado() == Global.ESTADO_SEG)
        {
           butEnviar.setText("Enviar a RH");                 
           gridSiprpView.setRendered(false);
           gridTrabalhadores.setRendered(false);
           gridAcidentado.setRendered(false);
           gridDadosAcidenteSegView.setRendered(false);
           gridDadosAcidenteRh.setRendered(false);
           gridDadosAcidenteRhView.setRendered(false);
           gridRecomendacoesHS.setRendered(false); 
           gridRecomendacoesViewHS.setRendered(false);  
           gridMedidasRH.setRendered(false);
           gridMedidasViewRH.setRendered(false);    
           gridMedico.setRendered(false);
           gridMedicoView.setRendered(false); 
           gridVerificacao.setRendered(false);
           gridVerificacaoView.setRendered(false); 
           gridImpressao.setRendered(false);
           gridImpressaoView.setRendered(false);                             
           
        }
        else if(a.getEstado() == Global.ESTADO_RH1)
        {
           butEnviar.setText("Enviar a HS"); 
           gridSiprpView.setRendered(false);
           gridAcidentadoView.setRendered(false);
           //gridDadosAcidenteSeg.setRendered(false);
           gridDadosAcidenteRhView.setRendered(false);
           gridRecomendacoesHS.setRendered(false); 
           gridRecomendacoesViewHS.setRendered(false);  
           gridMedidasRH.setRendered(false);
           gridMedidasViewRH.setRendered(false);  
           gridMedico.setRendered(false); 
           gridMedicoView.setRendered(false);   
           gridVerificacao.setRendered(false);
           gridVerificacaoView.setRendered(false); 
           gridImpressao.setRendered(false);
           gridImpressaoView.setRendered(false);                             
           
           
           if(a.getFormacao_shst().matches("y"))
           {
               rbFormacaoSHSTY.setSelected(new Boolean(true));
           }
           else
           {
               rbFormacaoSHSTN.setSelected(new Boolean(true));               
           }
           txtFormacaoSHSTNWhy.setText(a.getFormacao_shsht_n_why());
           
           if(a.getAcidentes_colaborador().matches("y"))
           {
               rbAcidentesColaboradorY.setSelected(new Boolean(true));
           }
           else
           {
               rbAcidentesColaboradorN.setSelected(new Boolean(true));               
           }
           
           txtNrAcidentesColaborador.setText(a.getNr_acidentes_colaborador());
           txtNrRelatorioAcidentesColaborador1.setText(a.getNr_relatorio_acidentes_colaborador_1());
           txtNrRelatorioAcidentesColaborador2.setText(a.getNr_relatorio_acidentes_colaborador_2());
           txtNrRelatorioAcidentesColaborador3.setText(a.getNr_relatorio_acidentes_colaborador_3());           
           txtNrRelatorioAcidentesColaborador4.setText(a.getNr_relatorio_acidentes_colaborador_4());           
           
           
           if(a.getAcidentes_colaboradores().matches("y"))
           {
               rbAcidentesColaboradoresY.setSelected(new Boolean(true));               
           }           
           else
           {
               rbAcidentesColaboradoresN.setSelected(new Boolean(true));               
           }
           
           txtNrAcidentesColaboradores.setText(a.getNr_acidentes_colaboradores());           
           txtNrRelatorioAcidentesColaboradores1.setText(a.getNr_relatorio_acidentes_colaboradores_1());
           txtNrRelatorioAcidentesColaboradores2.setText(a.getNr_relatorio_acidentes_colaboradores_2());
           txtNrRelatorioAcidentesColaboradores3.setText(a.getNr_relatorio_acidentes_colaboradores_3());           
           txtNrRelatorioAcidentesColaboradores4.setText(a.getNr_relatorio_acidentes_colaboradores_4());                      
        }
        stHeaderNr.setText(a.getHeader_nr());
        stHeaderDate.setText(a.getHeader_date());
        txtEmpresa.setText(a.getEmpresa());
        txtEstabelecimento.setText(a.getEstabelecimento());
        txtTrabalhador.setText(a.getTrabalhador());
        stNomeAcidentado.setText(a.getTrabalhador());
        stDataNascimento.setText(a.getData_nascimento());
        stDataAdmissao1.setText(a.getData_admissao());
        //////stDataAcidente.setText(a.getData_acidente());
        txtAveriguador.setText(a.getAveriguador());
        java.util.Date dtAcidente = (java.util.Date) a.getData_acidente();
        calDataOcorrencia.setValue(dtAcidente);        
        try
        {
            txtHorasTurno.setText(a.getHoras_turno().toString());            
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        
        stBI.setText(a.getBi());
        stMorada.setText(a.getMorada());
        txtCodPostal1.setText(a.getCod_postal1());
        txtCodPostal2.setText(a.getCod_postal2());        
        txtLocalidade.setText(a.getLocalidade());
        stContactoTelefonico.setText(a.getContacto_telefonico());
//        if(a.getTurno().matches("m"))
//        {
//            rbTurnoManha.setSelected(new Boolean(true));
//        }
//        if(a.getTurno().matches("t"))
//        {
//            rbTurnoTarde.setSelected(new Boolean(true));
//        }        
//        if(a.getTurno().matches("n"))
//        {
//            rbTurnoNoite.setSelected(new Boolean(true));
//        }        
//
        stTurno.setText(a.getTurno());
        stFuncao1.setText(a.getFuncao());
        drpHours.setSelected(a.getHours());
        drpMinutes.setSelected(a.getMinutes());
        txtLocal.setText(a.getLocal_trabalho());
        ////txtSeccao.setText(a.getSeccao());
        txtSubstancias.setText(a.getSubstancias());
        txtTarefa.setText(a.getTarefa());
        
//        txtSuperior.setText(a.getSuperior_hierarquico());
        txtCondicoes.setText(a.getCondicoes());
        txtTestemunhas.setText(a.getTestemunhas());
//        txtCausas.setText(a.getCausas());
        drpCausas.setSelected(a.getCausas());
        txtDescricao.setText(a.getDescricao());
        txtConclusoes.setText(a.getConclusoes());
        txtAccoes.setText(a.getAccoes());
        chkAveriguacaoPosterior.setSelected(new Boolean(false));        
        if(a.getAveriguacao_posterior().matches("y"))
        {
            chkAveriguacaoPosterior.setSelected(new Boolean(true));
        }
        txtAveriguacaoObs.setText(a.getAveriguacao_obs());

        if(getSessionBean1().getCurrentAnalise() != null)        
        {
            String folderName = getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(0,2) + getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(3);                    
            //fill images
            if(gridImages.getChildren().size() > 0)
            {
                gridImages.getChildren().clear();
            }         
            ServletContext theApplicationsServletContext =
                 (ServletContext) this.getExternalContext().getContext();
//             String imageFileFolder = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName);                
            
            
            File apacheAnaliseFolder = new File(theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName);
            if(apacheAnaliseFolder.exists())
            {
                Global global = new Global();
                global.deleteFolderFiles(apacheAnaliseFolder);
                System.out.println("FILES DELETED");
            }
            else
            {
                apacheAnaliseFolder.mkdir();            
            }            
            
            
            
             String imageFileFolder = Global.IMAGE_FOLDER + "/" + folderName;                            
             try
             {
                File f = new File(imageFileFolder);

                if(f.exists())
                {
                    File images[] = f.listFiles();
                    Arrays.sort(images);
                    for(int i=0;i<images.length;i++)
                    {
                        if(images[i].isFile())       
                        {
                            String imageName = images[i].getName();
                            ImageComponent newImg = new ImageComponent();
                            newImg.setId("img_comp" + imageName);  
                            
                            File apacheImage = new File( theApplicationsServletContext.getRealPath( Global.RESOURCES_IMAGE_FOLDER ) + "/analises/" + folderName + "/" + imageName);
                            Global global = new Global();
                            global.copyImage(images[i], apacheImage);

                            newImg.setUrl(Global.RESOURCES_IMAGE_FOLDER  + "/analises/" + folderName + "/" + imageName);                            
                            
                            
                            //newImg.setUrl("/resources/images/" + folderName + "/" + imageName);
                            newImg.setRendered(true);
                            gridImages.getChildren().add(newImg);
                            
                            Hyperlink ln = new Hyperlink();
                            ln.setId("img" + imageName); 
                            ln.setText("Apagar");
                            //ln.setValue(imageName);
                            Class args[] = { javax.faces.event.ActionEvent.class }; 
                            ApplicationFactory factory = (ApplicationFactory)

                            FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
                            //mb = factory.getApplication().createMethodBinding( "#{EditarQuestionario.lnkGrupo_onClick}", args);                        
                            MethodBinding mbAction = (MethodBinding) factory.getApplication().createMethodBinding("#{AnaliseAcidenteTrabalho.lnkDelImageReal_actionListener}", args);
                            ln.setActionListener(mbAction); 
                            gridImages.getChildren().add(ln);                                                                            
                        }
                    }                
                }
             }
             catch(Exception ex)
             {
                 ex.printStackTrace();
             }                    
        }

    }

    public String lnkLblTrabalhador_action() {
        // TODO: Replace with your code
        gridTrabalhadores.setRendered(true);
        //fillTrabalhadoresTable();
        return null;
    }

    public String lnkAnalisesAcidente_action() {
        // TODO: Replace with your code
//        savePageState();        
//        getSessionBean1().setNavFrom("AnaliseAcidenteTrabalho");        
//        getSessionBean1().setModoEdicaoUtilizador("edit");
//        return "user";
        getSessionBean1().setIeBug(true);                
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
//        String imageFileFolderTmp = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin());        
        String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin();                

        File ftmp = new File(imageFileFolderTmp);
        if( ftmp.exists() )
        {
            File files[] = ftmp.listFiles();

            for(int i=0;i<files.length;i++)
            {
                if(files[i].isFile())       
                {
                    files[i].delete();
                }
            }  
            
            ftmp.delete();
        }        
        String navFrom = getSessionBean1().getNavFrom();
        if(navFrom.matches("FormSeguranca"))
        {
            return "form_seguranca";
        }
        else if(navFrom.matches("FormRH"))
        {
            return "form_rh";
        }        
        else if(navFrom.matches("FormHS"))
        {
            return "form_hs";
        }                
        else if(navFrom.matches("FormMedico"))
        {
            return "form_medico";
        }
        return null;
    }

    public String lnkMoreRec1_action() {
        // TODO: Replace with your code
        getSessionBean1().setIeBug(true);
        int seq = gridRecomendacoes.getChildren().size();
        seq++;        
        HtmlPanelGrid grd = new HtmlPanelGrid();
        grd.setId("grd" + seq);
        grd.setColumns(3);
        grd.setColumnClasses("gridColLeft5, gridColLeft90,gridColLeft5");
        grd.setStyle("width: 100%");        
        
        StaticText st = new StaticText();
        st.setId("st" + seq);
        st.setText(seq + " .");
        st.setStyle("width: 24px");        
        grd.getChildren().add(st);
        
        TextArea ta = new TextArea();
        ta.setId("ta" + seq);        
        ta.setStyle("height: 24px; width: 98%");
        grd.getChildren().add(ta);  
        
        ImageHyperlink ln = new ImageHyperlink();
        ln.setId("ln" + seq);        
        ln.setWidth(9);
        ln.setHeight(9);
        ln.setImageURL("/resources/plus_more.gif");
        MethodBinding mbAction = this.getApplication().createMethodBinding("#{AnaliseAcidenteTrabalho.lnkMoreRec1_action}", null);
        ln.setAction(mbAction); 
        
        grd.getChildren().add(ln);          
        
        gridRecomendacoes.getChildren().add(grd);
        return null;
    }

    public String lnkMoreMed_action() {
        // TODO: Replace with your code
        getSessionBean1().setIeBug(true);        
        int seq = gridMedidas.getChildren().size();
        seq++;        
        HtmlPanelGrid grd = new HtmlPanelGrid();
        grd.setId("grdMedida" + seq);
        grd.setColumns(3);
        grd.setColumnClasses("gridColLeft5, gridColLeft90,gridColLeft5");
        grd.setStyle("width: 100%");        
        
        StaticText st = new StaticText();
        st.setId("stNrMedida" + seq);
        st.setText(seq + " .");
        st.setStyle("width: 24px");        
        grd.getChildren().add(st);
        
        TextArea ta = new TextArea();
        ta.setId("taMedida" + seq);        
        ta.setStyle("height: 24px; width: 98%");
        grd.getChildren().add(ta);  
        
        ImageHyperlink ln = new ImageHyperlink();
        ln.setId("lnMedidaMore" + seq);        
        ln.setWidth(9);
        ln.setHeight(9);
        ln.setImageURL("/resources/plus_more.gif");
        MethodBinding mbAction = this.getApplication().createMethodBinding("#{AnaliseAcidenteTrabalho.lnkMoreMed_action}", null);
        ln.setAction(mbAction); 
        
        grd.getChildren().add(ln);          
        
        gridMedidas.getChildren().add(grd);        
        return null;
    }
    
    public void lnkDelImageTmp_actionListener(ActionEvent ae) {
        String imageFilePath = "";
        //UIComponent eventSrc = ae.getComponent();
        Hyperlink lnk = (Hyperlink) ae.getComponent();
        String imageName = (String) lnk.getId();
        imageName = imageName.substring(3);
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
//         imageFilePath = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER);                
         imageFilePath = Global.IMAGE_FOLDER;                        
        imageFilePath += "/tmp" + getSessionBean1().getCurrentUser().getLogin() + "/" + imageName;     
        try
        {
            File f = new File(imageFilePath);
            if(f.exists())
            {        
                f.delete();
                ImageComponent img = (ImageComponent) gridImages.findComponent("img_comp" + imageName);
                gridImages.getChildren().remove(img);                                
                gridImages.getChildren().remove(lnk);
            }            
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }

    }    
    
    public void lnkDelImageReal_actionListener(ActionEvent ae) {  
        String imageFilePath = "";
        //UIComponent eventSrc = ae.getComponent();
        String folderName = getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(0,2) + getSessionBean1().getCurrentAnalise().getAnalise_nr().substring(3);                
        Hyperlink lnk = (Hyperlink) ae.getComponent();
        String imageName = (String) lnk.getId();
        imageName = imageName.substring(3);
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
//         imageFilePath = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/" + folderName);                        
         imageFilePath = Global.IMAGE_FOLDER + "/" + folderName;                                
         //imageFilePath = theApplicationsServletContext.getRealPath(IMAGE_URL);                
        imageFilePath += "/" + imageName;     
        try
        {
            File f = new File(imageFilePath);
            if(f.exists())
            {        
                f.delete();
                ImageComponent img = (ImageComponent) gridImages.findComponent("img_comp" + imageName);
                gridImages.getChildren().remove(img);                
                gridImages.getChildren().remove(lnk);
            }            
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }        
    }    
    

    private void initCalendars()
    {
        java.util.GregorianCalendar gcalendar = new java.util.GregorianCalendar();
        gcalendar.set(1900,1,1);
        calAvaliacaoIncap.setMinDate(gcalendar.getTime());
        java.util.GregorianCalendar gcalendar1 = new java.util.GregorianCalendar();
        gcalendar1.set(2099,1,1);
        calAvaliacaoIncap.setMaxDate(gcalendar1.getTime());

        calRevisaoIncap.setMinDate(gcalendar.getTime());
        calRevisaoIncap.setMaxDate(gcalendar1.getTime());                          
        
        calPeridoIncapDe.setMinDate(gcalendar.getTime());
        calPeridoIncapDe.setMaxDate(gcalendar1.getTime());                                  
        
        calPeriodoIncapA.setMinDate(gcalendar.getTime());
        calPeriodoIncapA.setMaxDate(gcalendar1.getTime());                                          
        
        calDataOcorrencia.setMinDate(gcalendar.getTime());
        calDataOcorrencia.setMaxDate(gcalendar1.getTime());    
    }

    public void chkMembroSupDir_processValueChange(ValueChangeEvent event) {
        // TODO: Replace with your code
        Boolean b = (Boolean) event.getNewValue();
        if(b.equals(new Boolean(true)))
        {
            lblEspecif1.setRendered(true);
            txtEspecif1.setRendered(true);
        }
        else
        {
            lblEspecif1.setRendered(false);
            txtEspecif1.setRendered(false);            
        }
    }

    public void chkMembroSupEsq_processValueChange(ValueChangeEvent event) {
        // TODO: Replace with your code
        Boolean b = (Boolean) event.getNewValue();
        if(b.equals(new Boolean(true)))
        {
            lblEspecif2.setRendered(true);
            txtEspecif2.setRendered(true);
        }
        else
        {
            lblEspecif2.setRendered(false);
            txtEspecif2.setRendered(false);            
        }        
    }

    public void chkMembroInfDir_processValueChange(ValueChangeEvent event) {
        // TODO: Replace with your code
        Boolean b = (Boolean) event.getNewValue();
        if(b.equals(new Boolean(true)))
        {
            lblEspecif3.setRendered(true);
            txtEspecif3.setRendered(true);
        }
        else
        {
            lblEspecif3.setRendered(false);
            txtEspecif3.setRendered(false);            
        }        
    }

    public void chkMembroInfEsq_processValueChange(ValueChangeEvent event) {
        // TODO: Replace with your code
        Boolean b = (Boolean) event.getNewValue();
        if(b.equals(new Boolean(true)))
        {
            lblEspecif4.setRendered(true);
            txtEspecif4.setRendered(true);
        }
        else
        {
            lblEspecif4.setRendered(false);
            txtEspecif4.setRendered(false);            
        }        
    }

//    public void drpTecnicos_processValueChange(ValueChangeEvent event) {
//        // TODO: Replace with your code
//        Integer selected = (Integer) drpTecnicos.getSelected();
//        if(selected.intValue() != 0)
//        {
//            UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
//            try
//            {
//                Utilizador u = udp.getUtilizador(selected);                
//                txtCap.setText(u.getCap());
//            }
//            catch(Exception ex)
//            {
//                ex.printStackTrace();                
//            }
//
//        }
//    }

//    public void drpMedicos_processValueChange(ValueChangeEvent event) {
//        // TODO: Replace with your code
//        Integer selected = (Integer) drpMedicos.getSelected();
//        if(selected.intValue() != 0)
//        {
//            UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
//            try
//            {
//                Utilizador u = udp.getUtilizador(selected);                
//                txtCedula.setText(u.getNumero_cedula());
//            }
//            catch(Exception ex)
//            {
//                ex.printStackTrace();
//            }            
//        }
//        
//    }

    public void chkRestricaoCargas_processValueChange(ValueChangeEvent event) {
        // TODO: Replace with your code
        Boolean b = (Boolean) event.getNewValue();
        if(b.equals(new Boolean(true)))
        {
            rbKgs2.setRendered(true);
            rbKgs5.setRendered(true);            
            rbKgs10.setRendered(true);            
            rbKgs15.setRendered(true);            
            rbKgsOutro.setRendered(true);            
            txtKgs.setRendered(true);
            stKgs2.setRendered(true);
            stKgs5.setRendered(true);            
            stKgs10.setRendered(true);            
            stKgs15.setRendered(true);            
            stKgsOutro.setRendered(true);            
            stKg.setRendered(true);                        
        }
        else
        {
            rbKgs2.setRendered(false);
            rbKgs5.setRendered(false);            
            rbKgs10.setRendered(false);            
            rbKgs15.setRendered(false);            
            rbKgsOutro.setRendered(false);            
            txtKgs.setRendered(false);
            stKgs2.setRendered(false);
            stKgs5.setRendered(false);            
            stKgs10.setRendered(false);            
            stKgs15.setRendered(false);            
            stKgsOutro.setRendered(false);            
            stKg.setRendered(false);                        
        }
    }
    
//    private void notifyNextSignature(Integer estado)
//    {
//        Integer tipo = null;
//        ArrayList list = null;
//        UtilizadoresDataProvider udp = new UtilizadoresDataProvider();        
//        switch(estado.intValue())
//        {
//            case Global.ESTADO_ASSINATURA_SEG:
//                tipo = new Integer(Global.TIPO_UTILIZADOR_SEGURANCA); // seguranca
//                try
//                {
//                    list = udp.getUtilizadoresListByTipo(tipo);     
//                    ListIterator iter = list.listIterator();
//                    while(iter.hasNext())
//                    {
//                        Utilizador u = (Utilizador) iter.next();
//                        //sendEmail(u.getEmail(), getSessionBean1().getCurrentUser().getEmail());
//                    }                    
//                }
//                catch(Exception ex)
//                {
//                    ex.printStackTrace();
//                }
//
//                break;
//
//            case Global.ESTADO_ASSINATURA_RH:
//                tipo = new Integer(Global.TIPO_UTILIZADOR_RH); // recursos humanos
//                try
//                {
//                    list = udp.getUtilizadoresListByTipo(tipo);     
//                    ListIterator iter = list.listIterator();
//                    while(iter.hasNext())
//                    {
//                        Utilizador u = (Utilizador) iter.next();
//                        //sendEmail(u.getEmail(), "", texto);
//                    }                    
//                }
//                catch(Exception ex)
//                {
//                    ex.printStackTrace();
//                }                
//                break;                
//        }
//    }
    
    private void sendMailToNextUser(AnaliseAcidente a, Integer estado)
    {
        Integer tipo = null;
        
        String assunto = "Comunicação de Análise de Acidentes de Trabalho";
        
        String texto_email = "<p>Esta &eacute; uma mensagem autom&aacute;tica da equipa da SIPRP:</p>";
        texto_email += "<p>Recebeu um novo processo de an&aacute;lise de acidente de trabalho para tratar.</p>";
        texto_email += "<p>Por favor, aceda a www.siprp.pt, separador colaboradores em 'Acesso &agrave; Gest&atilde;o de An&aacute;lises de Acidentes de Trabalho' e prossiga com a gest&atilde;o do processo " + a.getAnalise_nr()  + ".</p>";

        String responsavel_loja = "n";
        switch (estado.intValue())
        {
            case Global.ESTADO_RH1:
                tipo = new Integer(Global.TIPO_UTILIZADOR_RH);
                break;
            case Global.ESTADO_HS:
                tipo = new Integer(Global.TIPO_UTILIZADOR_HS);
                break;
            case Global.ESTADO_RH2:
                tipo = new Integer(Global.TIPO_UTILIZADOR_RH);
                break;
            case Global.ESTADO_CONSOLIDACAO:
                tipo = new Integer(Global.TIPO_UTILIZADOR_HS);
                break;
            case Global.ESTADO_ASSINATURA_SEG:
                tipo =new Integer(Global.TIPO_UTILIZADOR_SEGURANCA);
                responsavel_loja = "y";
                break;
            case Global.ESTADO_ASSINATURA_RH:
                tipo = new Integer(Global.TIPO_UTILIZADOR_RH);
                responsavel_loja = "y";                
                break;
            case Global.ESTADO_FECHAR:
                tipo = new Integer(Global.TIPO_UTILIZADOR_HS);
                break;
        }

//        if(estado.intValue() == Global.ESTADO_FECHAR)            
//        {
//            tipo = new Integer(Global.TIPO_UTILIZADOR_HS);  // hs
//        }
//        else
//        {
//            tipo = estado;
//        }
        
        UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
        try
        {
            ArrayList list = udp.getUtilizadoresListByTipo(tipo, responsavel_loja, a.getEstabelecimento_id());
            ListIterator iter = list.listIterator();
            while(iter.hasNext())
            {
                Utilizador u = (Utilizador) iter.next();
                System.out.println("USER MAIL NEXT FASE : " + u.getLogin() + " ; " + u.getEmail());
                try
                {
                    sendEmail(u.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email);                    
                }
                catch(Exception ex1)
                {
                    ex1.printStackTrace();
                    System.out.println("MAIL ERROR : " + ex1.getMessage());                    
                }

            }
        }
        catch(Exception ex)
        {
            //ex.printStackTrace();
        }

    }
    
  private void sendEmailResponsavelHierarquico(AnaliseAcidente a)    
  {     
        Acidentado ac = getSessionBean1().getAcidentado();
        String assunto = "Comunicação de Análise de Acidentes de Trabalho de " + ac.getNome();
        
        String data_acidente = "";
        try
        {
            java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime());
            data_acidente = utils.Utils.dateToYYYYMMDD(ddate);            
        }
        catch(Exception ex){}
        
        String texto_email = "<p style='text-align: justify; font-family: arial, sans-serif'>Caro(a) Colega,</p>";
        texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Na sequ&ecirc;ncia do acidente de trabalho do colaborador ";
        texto_email += ac.getNome();
        texto_email += " no dia " + data_acidente;
        texto_email += ", vimos pelo presente remeter c&oacute;pia da an&aacute;lise do acidente " + a.getAnalise_nr() + " que se encontra em processo de averigua&ccedil;&atilde;o pelo departamento de Seguran&ccedil;a, Recursos Humanos e pela SIPRP para seu conhecimento. Caso tenha qualquer informa&ccedil;&atilde;o importante sobre o processo ou pretenda esclarecimentos adicionais contacte, por favor, a sec&ccedil;&atilde;o de Recursos Humanos.</p>";
        texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Cumprimentos.</p>";
        try
        {
            sendEmail(ac.getEmail_superior_hierarquico(), Global.ENDERECO_ENVIO, assunto, texto_email);                  
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
  }
  
  private void sendEmailFimProcesso(AnaliseAcidente a)
  {
         Acidentado ac = getSessionBean1().getAcidentado();       
         String assunto = "Fecho do Processo de Análise de Acidente de Trabalho de " + ac.getNome();      
         UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
         ArrayList responsavelRh_list = udp.getResponsavelRhList( a.getEstabelecimento_id() );
         if(responsavelRh_list != null)
         {
             ListIterator iter = responsavelRh_list.listIterator();
             while(iter.hasNext())
             {
                 Utilizador u = (Utilizador) iter.next();
                String texto_email = "<p style='text-align: justify; font-family: arial, sans-serif'>Exmo. (a) Senhor(a), " + u.getNome() + "</p>";
                texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Informamos que o processo de an&aacute;lise de acidente de trabalho n&#186; " + a.getAnalise_nr() + " se encontra finalizado, ";
                texto_email += "pelo que solicitamos a sua impress&atilde;o e arquivamento em pasta pr&oacute;pria, juntamente com a participa&ccedil;&atilde;o de sinistro &agrave; seguradora.</p>";
                texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Caso pretenda qualquer esclarecimento, contacte-nos, por favor, atrav&eacute;s de acidentes.auchan@siprp.pt ou pelo telefone 213 504 540.</p>";
                texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Os melhores cumprimentos.</p>";
                texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>SIPRP </p>";                
                try
                {
                    sendEmail(u.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email);                  
                }
                catch(Exception ex)
                {
                    ex.printStackTrace();
                }                 
             }
         }
  }
  
  private void sendEmailToRhFase4(AnaliseAcidente a)
  {
      System.out.println("SEND EMAIL TO RH FASE 4");
         Acidentado ac = getSessionBean1().getAcidentado();       
         //String assunto = "SIPRP &#175; Fecho do Processo de An&aacute;lise de Acidente de Trabalho n&#186; " + a.getAnalise_nr() + " &#175; Ficheiro para Impress&atilde;o";
        String assunto = "SIPRP - Fecho do Processo de Análise de Acidente de Trabalho nº " + a.getAnalise_nr() + " - Ficheiro para Impressão";         
         
         UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
         try
         {
            Utilizador urh = udp.getUtilizador(a.getRh_fase4());  
            String texto_email = "<p style='text-align: justify; font-family: arial, sans-serif'>Exmo. (a) Senhor(a), </p>";    
            texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Confirmamos que o processo de An&aacute;lise de Acidente de Trabalho n&#186 " + a.getAnalise_nr()+ " se encontra encerrado ap&oacute;s o preenchimento e valida&ccedil;&atilde;o de todos os intervenientes.</p>";
            texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Sugerimos que imprima o ficheiro que enviamos em anexo e o junte &agrave; Participa&ccedil;&atilde;o de Sinistro &agrave; Seguradora para dar conhecimento ao M&eacute;dico do Trabalho do seu estabelecimento. Ap&oacute;s o seu conhecimento, aconselhamos que entregue uma c&oacute;pia da Ficha de An&aacute;lise de Acidente de Trabalho &agrave; equipa de Sa&uacute;de Ocupacional, para que esta a arquive no processo cl&iacute;nico do trabalhador antes de juntar toda a documenta&ccedil;&atilde;o no processo individual do colaborador nos Recursos Humanos.</p>";            
            texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Agradecemos a sua colabora&ccedil;&atilde;o e ficamos ao dispor para qualquer esclarecimento atrav&eacute;s dos telefones 213 504 544 (Catarina Leonardo) ou 213 504 542 (S&oacute;nia Campos).</p>";            
            texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>Os melhores cumprimentos,</p>";            
            texto_email += "<p style='text-align: justify; font-family: arial, sans-serif'>A equipa da SIPRP</p>";    
            try
            {
                sendEmailWithPdf(a, urh.getEmail(), Global.ENDERECO_ENVIO, assunto, texto_email);                  
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
                System.out.println("EMAIL FASE 4 ERROR : " + ex.getMessage());
            }                             
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }

  }
  
//  private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email) throws Exception
//  {
//        Properties props = new Properties(); 
//        //props.put("mail.transport.protocol", "smtp"); 
//        props.put("mail.smtp.host", "smtp.netcabo.pt"); 
//        props.put("mail.from", emailFrom); 
//        Session session1 = Session.getInstance(props); 
//        Message msg = new MimeMessage(session1); 
//
////    try 
////    { 
//        //Address Email_TO = new InternetAddress("myemail@bol.com.br");         
//        msg.setFrom(new InternetAddress(emailFrom));
//        InternetAddress[] address = {new InternetAddress(emailTo)};
//        msg.setRecipients(Message.RecipientType.TO, address);
//        msg.setSubject(assunto);
//        msg.setSentDate(new Date()); 
//        Multipart multipart = new MimeMultipart();
//        BodyPart msgBodyPart = new MimeBodyPart();
//        String html;    
//        html="<html><head>  <meta content='text/html;charset=ISO-8859-1' http-equiv='Content-Type'></head>";
//        html+="<body bgcolor='#ffffff' text='#000000'>";
//        html+= texto_email;
//        html+="<body></html>";
//        msgBodyPart.setContent(html, "text/html");
//        multipart.addBodyPart(msgBodyPart);
//        msg.setContent(multipart);           
//        Transport.send(msg); 
//        System.out.println("Email Enviado !!!! "); 
////    } 
////    catch (Exception ex)
////    { 
////        System.out.println("MAIL ERROR : " + ex.getMessage());
////        ex.printStackTrace(); 
////    } 
//      
//  } 
  
 public class SMTPAuthenticator extends Authenticator {   
 public PasswordAuthentication getPasswordAuthentication() {   
 String username = "lluis";   
 String password = "654321";   
 return new PasswordAuthentication(username, password);   
 }     
 }
  private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email) throws Exception  
  {
        Properties props = new Properties(); 
        //props.put("mail.transport.protocol", "smtp"); 
        props.put("mail.smtp.host", "mail2.evolute.pt"); 
        props.put("mail.from", emailFrom); 
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.user", "lluis");
        props.put("mail.smtp.password", "654321");        
//        Session session1 = Session.getInstance(props); 
        Authenticator auth = new SMTPAuthenticator();   
        Session session = Session.getDefaultInstance(props, auth);         
        
        Message msg = new MimeMessage(session); 
        msg.setFrom(new InternetAddress(emailFrom));
        InternetAddress[] address = {new InternetAddress(emailTo)};
        msg.setRecipients(Message.RecipientType.TO, address);
        ((MimeMessage)msg).setSubject(assunto, "UTF-8");
        msg.setSentDate(new Date()); 
        Multipart multipart = new MimeMultipart();
        BodyPart msgBodyPart = new MimeBodyPart();
        String html;    
        html="<html><head>  <meta content='text/html;charset=ISO-8859-1' http-equiv='Content-Type'></head>";
        html+="<body bgcolor='#ffffff' text='#000000'>";
        html+= texto_email;
        html+="<body></html>";
        msgBodyPart.setContent(html, "text/html");
        multipart.addBodyPart(msgBodyPart);
        msg.setContent(multipart);           
        Transport.send(msg); 
        System.out.println("Email Enviado !!!! ");         
      
  }
  
  private void sendEmailWithPdf(AnaliseAcidente a, String emailTo, String emailFrom, String assunto, String texto_email) throws Exception  
  {
      System.out.println("SEND EMAIL WITH PDF");      
        UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
        Utilizador ut = udp.getUtilizador(a.getTecnico_saude_id());
        Utilizador um = udp.getUtilizador(a.getMedico_id());        
        AnalisesDataProvider adp = new AnalisesDataProvider();
        Acidentado ac = adp.getAcidentado(a.getAcidentado_id());
        Estabelecimento e = new Estabelecimento();
        e.setId(a.getEstabelecimento_id());
        e.setNome(adp.getEstabelecimentoNome(a.getEstabelecimento_id()));
        Seccao s = adp.getSeccao(a.getSeccao_id());        
        Causa c = adp.getCausa(a.getCausas());
        ArrayList recList = adp.getRecomendacoesByAnalise(a.getId());
        Recomendacao[] recArray = new Recomendacao[recList.size()];
        ListIterator iter = recList.listIterator();
        int i = 0;
        while(iter.hasNext())
        {
            Recomendacao rec = (Recomendacao) iter.next();
            recArray[i] = rec;
            i++;
        }
        //Recomendacao recArray[] = (Recomendacao)recList.toArray();
        ArrayList medList = adp.getMedidasByAnalise(a.getId());
        //Medida medArray[] = (Medida)medList.toArray();
        Medida[] medArray = new Medida[medList.size()];        
        iter = medList.listIterator();        
        i = 0;
        while(iter.hasNext())
        {
            Medida med = (Medida) iter.next();
            medArray[i] = med;
            i++;
        }
        
        PdfGenerator pdf = new PdfGenerator(Global.IMAGE_FOLDER, e, ut, um, a, ac, s, recArray, medArray, c);
        
        ByteArrayDataSource ds = new ByteArrayDataSource(pdf.generatePdf(), 
                    "application/pdf");      
        Properties props = new Properties(); 
        //props.put("mail.transport.protocol", "smtp"); 
        props.put("mail.smtp.host", "mail2.evolute.pt"); 
        props.put("mail.from", emailFrom); 
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.user", "lluis");
        props.put("mail.smtp.password", "654321");        
//        Session session1 = Session.getInstance(props); 
        Authenticator auth = new SMTPAuthenticator();   
        Session session = Session.getDefaultInstance(props, auth);         
        
        Message msg = new MimeMessage(session); 
        msg.setFrom(new InternetAddress(emailFrom));
        InternetAddress[] address = {new InternetAddress(emailTo)};
        msg.setRecipients(Message.RecipientType.TO, address);
        ((MimeMessage)msg).setSubject(assunto, "UTF-8");
        msg.setSentDate(new Date()); 
        Multipart multipart = new MimeMultipart();
        BodyPart msgBodyPart = new MimeBodyPart();
        String html;    
        html="<html><head>  <meta content='text/html;charset=ISO-8859-1' http-equiv='Content-Type'></head>";
        html+="<body bgcolor='#ffffff' text='#000000'>";
        html+= "<div>" + texto_email + "</div>";
        html+="<body></html>";
        msgBodyPart.setContent(html, "text/html");
        multipart.addBodyPart(msgBodyPart);
        
        MimeBodyPart pdfPart = new MimeBodyPart();
        //pdfPart.setContent(ds,"application/pdf");
        pdfPart.setDataHandler(new DataHandler(ds));
        pdfPart.setHeader("Content-Transfer-Encoding","base64");
        pdfPart.setHeader("Content-Disposition","attachment");
        String pdfname = "Analise" + a.getAnalise_nr();
        pdfPart.setFileName(pdfname);
        multipart.addBodyPart(pdfPart,1);        
        msg.setContent(multipart);           
        Transport.send(msg); 
        System.out.println("Email Pdf Enviado !!!! " + emailTo);               
  }

    public String butImprimir_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
//       AnaliseAcidente a = getSessionBean1().getCurrentAnalise();
//       if(a.getEstado().intValue() == ESTADO_IMPRESSAO)
//       {
//               Pdf pdf = new Pdf();
//               pdf.generatePdf(a);       
//       }    
        
            if(validationOk())
            {
                AnaliseAcidente a = fillAnaliseFields();
                Acidentado ac = null;
                ArrayList recs = null;
                ArrayList meds = null;
                int estado = a.getEstado().intValue();
                //if(estado == ESTADO_SEG || estado == ESTADO_RH1)
//                if(estado == Global.ESTADO_RH1)                
//                {
//                    ac = fillAcidentadoFields();                    
//                }         
//                else if(estado == Global.ESTADO_HS)
//                {
//                    a.setTecnico_saude_id(getSessionBean1().getCurrentUser().getId());                                
//                    recs = fillAnaliseRecomendacoesHs(a);
//                }        
//                else if(estado == Global.ESTADO_RH2)
//                {
//                    meds = fillAnaliseMedidasRh(a);
//                }                
//                int novo_estado = a.getEstado().intValue();
//                
//                if(a.getCorrecao().matches("y"))
//                {
//                    a.setCorrecao("n");
//                    a.setEstado(a.getEstado_antes_correcao());
//                    a.setEstado_antes_correcao(null);
//                    a.setObservacoes_correcao("");
//                }
//                else
//                {
//                    if(novo_estado < Global.ESTADO_CONCLUIDO)
//                    {
//                        novo_estado++;
//    //                    if(novo_estado == ESTADO_MEDICO)
//    //                    {
//    //                        novo_estado++;  //skip medico
//    //                    }
//                        if(novo_estado == Global.ESTADO_ASSINATURAS)
//                        {
//                            a.setEstado_assinatura(new Integer(ESTADO_ASSINATURA_1));
//                            notifyNextSignature(new Integer(ESTADO_ASSINATURA_1));                        
//                        }
//                    }
//                    a.setEstado(new Integer(novo_estado));                     
//                }

                try
                {
                    update(a, ac, recs, meds);
                    chkVerRespRh.setDisabled(true);
                    //createImagesFolder(analiseId.toString());
//                    updateImagesFolder(a.getId().toString()); 
//                    sendMailToNextUser(new Integer(novo_estado));
//                    String navFrom = getSessionBean1().getNavFrom();
//                    if(navFrom.matches("FormSeguranca"))
//                    {
//                        return "form_seguranca";
//                    }     
//                    else if(navFrom.matches("FormRH"))
//                    {
//                        return "form_rh";                        
//                    }
//                    else if(navFrom.matches("FormHS"))
//                    {
//                        return "form_hs";                        
//                    }                                        
//                    else if(navFrom.matches("FormMedico"))
//                    {
//                        return "form_medico";                        
//                    }                                                                                
                }
                catch(Exception ex)
                {
                    getSessionBean1().setMsg("Erro na actualiza&ccedil;&atilde;o da an&aacute;lise !");
                    ex.printStackTrace();
                }
            }            
        
        return null;
    }
    
    private void buildPdf(AnaliseAcidente a)
    {
        
        // create pdf folder
        String pdf_folder = createPdfFolder(a.getId().toString());
        if(pdf_folder != null)
        {
            hidDisableEnviar.setValue(a.getId().toString());
            Pdf pdf = new Pdf();
            pdf.generatePdf(pdf_folder, a);
        }
    }
    
    
    private String createPdfFolder(String folderName)
    {
        ServletContext theApplicationsServletContext =
             (ServletContext) this.getExternalContext().getContext();
         String pdfFileFolder = theApplicationsServletContext.getRealPath(PDFS_FOLDER_URL + "/" + folderName);                
         try
         {
            //String imageFileFolderTmp = theApplicationsServletContext.getRealPath(IMAGE_URL + "/tmp" + getSessionBean1().getCurrentUser().getLogin());        
            File folder = new File(pdfFileFolder);
            if(! folder.exists())
            {
                folder.mkdir();
            }
            else
            {
                //remove all existing files
                File files[] = folder.listFiles();

                for(int i=0;i<files.length;i++)
                {
                    if(files[i].isFile())       
                    {
                        // delete
                        boolean success = files[i].delete();
                    }
                }                
            }
            return pdfFileFolder;
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
             return null;
         }
        
    }        

    public String butProcurarTrab_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        boolean booNrOk = false;
        boolean booNomeOk = false;        
        String nr_mecano = null;
        String nome = null;        
        if(txtNrMecanografico.getText() != null)
        {
            nr_mecano = (String) txtNrMecanografico.getText();
            if(nr_mecano.trim().length() > 0)
            {
                booNrOk = true;
            }
            else
            {
                nr_mecano = null;
            }
        }
        
        if(txtNomeTrabalhador.getText() != null)
        {
            nome = (String) txtNomeTrabalhador.getText();
            if(nome.trim().length() > 0)
            {
                booNomeOk = true;
            }
            else
            {
                nome = null;
            }            
        }        
        
        if(! booNrOk && !booNomeOk)
        {
            getSessionBean1().setMsg("Tem de preencher Numero Mecanogr&aacute;fico ou Nome");
            return null;
        }
        
        AnalisesDataProvider adp = new AnalisesDataProvider();
        Trabalhador t = null;
        if(nome != null)
        {
            nome = utils.Utils.textToUnicode( nome.toUpperCase());            
        }
        try
        {
            ArrayList list = adp.searchTrabalhador(getSessionBean1().getCurrentUser().getEmpresa_id(), getSessionBean1().getCurrentUser().getEstabelecimento_id(), nr_mecano, nome );
            if(list.size() == 1)
            {
                t = (Trabalhador) list.get(0);
                txtTrabalhador.setText(t.getNome());     
                txtNomeAcidentado.setText(t.getNome());
                txtDataNascimento.setText(t.getData_nascimento());                 
                Acidentado a = new Acidentado();
                a.setTrabalhador_id(t.getId());
                a.setData_nascimento(t.getData_nascimento());
                a.setNome(t.getNome());  
                a.setFuncao(utils.Utils.unicodeToHTML(t.getFuncao()));
                a.setData_admissao(t.getData_admissao());     
                a.setNumero_mecanografico(t.getNumero_mecanografico());
                getSessionBean1().setAcidentado(a);    
                gridSiprp.setRendered(true);
                gridDadosAcidenteSeg.setRendered(true);     
                gridTrabalhadores.setRendered(false);                
            }
            else
            {
                tblTrabalhadores.setRendered(true);
                getSessionBean1().getTrabalhadoresListDataProvider().setList(list);
            }
            if(getSessionBean1().getCurrentAnalise() != null) // new analise)
            {
                gridTrabalhadores.setRendered(false);
            }                        
        }
        catch(Exception ex)
        {
            getSessionBean1().setMsg("Trabalhador inexistente ! ");   
            tblTrabalhadores.setRendered(false);  
            txtTrabalhador.setText("");                 
            gridSiprp.setRendered(false);
            gridDadosAcidenteSeg.setRendered(false);                            
            ex.printStackTrace();
        }

        return null;
    }

    public String lnkPOR_action() {
        // TODO: Replace with your code
        getSessionBean1().setIeBug(true);        
        Trabalhador t = getTrabalhadorRowData();
        Acidentado ac = setAcidentado(t);
        gridSiprp.setRendered(true);   
        gridAcidentadoView.setRendered(true);
        gridDadosAcidenteSeg.setRendered(true);                        
        gridTrabalhadores.setRendered(false);
        fillAcidentadoView(ac);
        return null;
    }

    public String lnkNomeTrabalhador_action() {
        // TODO: Replace with your code
        getSessionBean1().setIeBug(true);
        Trabalhador t = getTrabalhadorRowData();
        Acidentado ac = setAcidentado(t); 
        gridSiprp.setRendered(true);    
        gridAcidentadoView.setRendered(true);        
        gridDadosAcidenteSeg.setRendered(true);                                
        gridTrabalhadores.setRendered(false);   
        fillAcidentadoView(ac);        
        return null;
    }

    public String lnkEstabelecimentoTrabalhador_action() {
        // TODO: Replace with your code
        getSessionBean1().setIeBug(true);        
        Trabalhador t = getTrabalhadorRowData();
        Acidentado ac = setAcidentado(t);
        gridSiprp.setRendered(true);
        gridAcidentadoView.setRendered(true);        
        gridDadosAcidenteSeg.setRendered(true);
        gridTrabalhadores.setRendered(false);
        fillAcidentadoView(ac);        
        return null;
    }
    
    private Trabalhador getTrabalhadorRowData()
    {
        RowKey rk = tableRowGroup1.getRowKey();
        int k = Integer.parseInt(rk.getRowId());        
        TrabalhadoresListDataProvider provider = (TrabalhadoresListDataProvider) tableRowGroup1.getSourceData();
        ArrayList list = (ArrayList) provider.getList();
        Trabalhador t = (Trabalhador)list.get(k);
        return t;
    }  
    
    private Acidentado setAcidentado(Trabalhador t)
    {
        txtTrabalhador.setText(t.getNome());     
        txtNomeAcidentado.setText(t.getNome());
        txtDataNascimento.setText(t.getData_nascimento());                 
        Acidentado a = new Acidentado();
        a.setTrabalhador_id(t.getId());
        a.setData_nascimento(t.getData_nascimento());
        a.setNome(t.getNome());  
        a.setMorada("");
        a.setFuncao(utils.Utils.unicodeToHTML(t.getFuncao()));
        a.setData_admissao(t.getData_admissao());     
        a.setNumero_mecanografico(t.getNumero_mecanografico());
        a.setEstabelecimento_origem(t.getEstabelecimento());
        getSessionBean1().setAcidentado(a); 
        return a;        
    }

    public String butCorrecao_action() {
        // TODO: Process the button click action. Return value is a navigation
        // case name where null will return to the same page.
        getSessionBean1().setIeBug(true);
        getSessionBean1().setCorrecao(null);
        return "correcao";
    }

    public String lnkNewUser_action() {
        // TODO: Replace with your code
        
        return null;
    }
    
    private boolean isRecomendacoesEmpty()
    {
        boolean res = true;
        
        for(int i=0; i < gridRecomendacoes.getChildren().size(); i++)
        {
            HtmlPanelGrid g = (HtmlPanelGrid) gridRecomendacoes.getChildren().get(i);
            TextArea t = (TextArea) g.getChildren().get(1);
            if(t.getText() != null)
            {
                String txt = (String) t.getText();
                if(txt.trim().length() > 0)
                {
                    res = false;
                    break;
                }
            }
        }
        
        return res;
    }
    
    private boolean isMedidasEmpty()
    {
        boolean res = true;
        
        for(int i=0; i < gridMedidas.getChildren().size(); i++)
        {
            HtmlPanelGrid g = (HtmlPanelGrid) gridMedidas.getChildren().get(i);
            TextArea t = (TextArea) g.getChildren().get(1);
            if(t.getText() != null)
            {
                String txt = (String) t.getText();
                if(txt.trim().length() > 0)
                {
                    res = false;
                    break;
                }
            }
        }
        
        return res;
    }    

    public void drpDepartamento_processValueChange(ValueChangeEvent event) {
        // TODO: Replace with your code
        
        AnalisesDataProvider adp = new AnalisesDataProvider();
        Integer departamento_id = (Integer) drpDepartamento.getSelected();
       try
       {
           if(departamento_id.intValue()== 0)
           {
                getSessionBean1().setSeccaoOptions(adp.getSeccoesList(null));               
           }
           else
           {
                getSessionBean1().setSeccaoOptions(adp.getSeccoesList(departamento_id));                              
           }

            drpSeccao.setSelected(new Integer(0));
       }
       catch(Exception ex)
       {
           ex.printStackTrace();
       }
        hidAnchor.setValue("dados");
    }

    public String lnkAjuda_action() {
        // TODO: Replace with your code
//        ServletContext theApplicationsServletContext =
//             (ServletContext) this.getExternalContext().getContext();
//         String pdfFolderPath = theApplicationsServletContext.getRealPath(Global.PDF_FOLDER_URL); 
//         String pdfFilePath = pdfFolderPath + "/Ajuda.pdf";  
//         
//         Global global = new Global();
//         try
//         {
//            global.showPdf(pdfFilePath);
//         }
//         catch(Exception ex)
//         {
//             ex.printStackTrace();
//         }   
        getSessionBean1().setIeBug(true);                
        return null;
    }
    
    private boolean checkRecomendacoesLen()
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        HashMap meta = new HashMap();
        try
        {
            meta = adp.getMetaData("recomendacoes");
            ArrayList list = new ArrayList();
            ListIterator iter = gridRecomendacoes.getChildren().listIterator();
            while(iter.hasNext())
            {
                HtmlPanelGrid grd = (HtmlPanelGrid)iter.next();
                TextArea ta = (TextArea) grd.getChildren().get(1);
                if(ta.getText() != null )
                {
                    String txt = (String) ta.getText();
                    if(txt.length() > 0)
                    {
                        int len = ( (Integer) meta.get("recomendacao") ).intValue();
                        if(txt.length() > len)
                        {
                            getSessionBean1().setMsg("Os Campos Recomenda&ccedil;&otilde;es n&atilde;o podem exceder " + len + " caracteres!");
                            return false;
                        }
                    }
                }
            }        
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            return false;
        }
        return true;
    }   
    
    private boolean checkMedidasLen()
    {
        AnalisesDataProvider adp = new AnalisesDataProvider();
        HashMap meta = new HashMap();

        try
        {
            meta = adp.getMetaData("medidas");
            ArrayList list = new ArrayList();
            ListIterator iter = gridMedidas.getChildren().listIterator();
            while(iter.hasNext())
            {
                HtmlPanelGrid grd = (HtmlPanelGrid)iter.next();
                TextArea ta = (TextArea) grd.getChildren().get(1);
                if(ta.getText() != null )
                {
                    String txt = (String) ta.getText();
                    if(txt.length() > 0)
                    {
                        int len = ( (Integer) meta.get("medida") ).intValue();
                        if(txt.length() > len)
                        {
                            getSessionBean1().setMsg("Os Campos Medidas n&atilde;o podem exceder " + len + " caracteres!");
                            return false;
                        }                        
                    }
                }
            }                    
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            return false;
        }

        return true;        
    }    

}

