package siprp.medicina.processo.ui;

import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import static com.evolute.utils.strings.UnicodeLatin1Map.iacute;
import static com.evolute.utils.strings.UnicodeLatin1Map.otilde;
import static info.clearthought.layout.TableLayoutConstants.FILL;
import static info.clearthought.layout.TableLayoutConstants.MINIMUM;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.*;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_CONSULTA_MARCACAO_OBSERVACOES;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.CREATE_EXAME;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SAVE_CONSULTA;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_EMAIL;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_CONSULTA_MARCACAO_OBSERVACAO;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_EMAIL;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_EXAME_MARCACAO_OBSERVACAO;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.SELECT_PROCESSO;
import static siprp.medicina.processo.logic.MedicinaProcessoLogic.LOAD_TRABALHADOR;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;

import java.awt.CardLayout;
import java.util.Date;
import java.util.HashMap;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import siprp.database.cayenne.objects.Trabalhadores;
import siprp.database.cayenne.objects.TrabalhadoresConsultas;
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatas;
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasEmails;
import siprp.database.cayenne.objects.TrabalhadoresConsultasDatasObservacoes;
import siprp.database.cayenne.objects.TrabalhadoresEcds;
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatas;
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasEmails;
import siprp.database.cayenne.objects.TrabalhadoresEcdsDatasObservacoes;
import siprp.database.cayenne.objects.TrabalhadoresProcesso;
import siprp.logic.SIPRPLogic.LeafUIActionBinding;
import siprp.ui.SIPRPWindow;

public class ProcessoDadosPanel extends JPanel
{
	private static final long serialVersionUID = 1L;
	private final SIPRPWindow parentWindow;

	private static final String PANEL_START_NAME = "START_PANEL";

	private static final String PANEL_TRABALHADOR_NAME = "TRABALHADOR_PANEL";

	private static final String PANEL_PROCESSO_NAME = "PROCESSO_PANEL";

	private static final String PANEL_CONSULTA_NAME = "PANEL_CONSULTA_NAME";
	private static final String PANEL_CONSULTA_MARCACAO_NAME = "PANEL_CONSULTA_MARCACAO_NAME";
	private static final String PANEL_CONSULTA_MARCACAO_EMAIL_NAME = "PANEL_CONSULTA_MARCACAO_EMAIL_NAME";
	private static final String PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME = "PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME";

	private static final String PANEL_EXAME_NAME = "EXAME_PANEL";
	private static final String PANEL_EXAME_MARCACAO_NAME = "PANEL_EXAME_MARCACAO_NAME";
	private static final String PANEL_EXAME_MARCACAO_EMAIL_NAME = "PANEL_EXAME_MARCACAO_EMAIL_NAME";
	private static final String PANEL_EXAME_MARCACAO_OBSERVACAO_NAME = "PANEL_EXAME_MARCACAO_OBSERVACAO_NAME";

	private final CardLayout cardLayout = new CardLayout();

	// panels
	private final JPanel panelExame = new JPanel();
	private final JPanel panelExameMarcacao = new JPanel();
	private final JPanel panelExameMarcacaoEmail = new JPanel();
	private final JPanel panelExameMarcacaoObservacao = new JPanel();

	private final JPanel panelConsulta = new JPanel();
	private final JPanel panelConsultaMarcacao = new JPanel();
	private final JPanel panelConsultaMarcacaoEmail = new JPanel();
	private final JPanel panelConsultaMarcacaoObservacao = new JPanel();

	private final JPanel panelProcesso = new JPanel();

	private final JPanel panelTrabalhador = new JPanel();

	private final JPanel panelStart = new JPanel();

	// trabalhador
	private final JLabel labelTrabalhadorNome = new JLabel( "Nome" );
	private final JLabel labelTrabalhadorSexo = new JLabel( "Sexo" );
	private final JLabel labelTrabalhadorDataNascimento = new JLabel( "Data de Nascimento" );
	private final JLabel labelTrabalhadorNacionalidade = new JLabel( "Nacionalidade" );
	private final JLabel labelTrabalhadorObservacoes = new JLabel( "Observa" + ccedil + otilde + "es" );

	private final LeafInputField<String> inputTrabalhadorNome = new LeafInputField<String>();
	private final LeafInputField<HashMap<String,String>> inputTrabalhadorSexo = new LeafInputField<HashMap<String,String>>();
	private final LeafInputField<Date> inputTrabalhadorDataNascimento = new LeafInputField<Date>();
	private final LeafInputField<String> inputTrabalhadorNacionalidade = new LeafInputField<String>();
	private final LeafInputField<String> inputTrabalhadorObservacoes = new LeafInputField<String>();

	// processo

	private final JLabel labelProcessoEstado = new JLabel( "Estado" );
	private final JLabel labelProcessoDataInicio = new JLabel( "In" + iacute + "cio" );
	private final JLabel labelProcessoDataFim = new JLabel( "Fim" );
	private final JLabel labelProcessoMotivo = new JLabel( "Motivo" );

	private final LeafInputField<HashMap<String,String>> inputProcessoEstado = new LeafInputField<HashMap<String,String>>();
	private final LeafInputField<Date> inputProcessoDataInicio = new LeafInputField<Date>();
	private final LeafInputField<Date> inputProcessoDataFim = new LeafInputField<Date>();
	private final LeafInputField<HashMap<Integer,String>> inputProcessoMotivo = new LeafInputField<HashMap<Integer,String>>();

	// consulta
	private final JLabel labelConsultaEstado = new JLabel( "Estado" );
	private final JLabel labelConsultaData = new JLabel( "Data" );

	private final LeafInputField<HashMap<Integer, String>> inputConsultaEstado = new LeafInputField<HashMap<Integer, String>>();
	private final LeafInputField<Date> inputConsultaData = new LeafInputField<Date>();

	// marcacao consulta
	private final JLabel labelConsultaMarcacaoEstado = new JLabel( "Estado" );
	private final JLabel labelConsultaMarcacaoData = new JLabel( "Data" );

	private final LeafInputField<HashMap<Integer, String>> inputConsultaMarcacaoEstado = new LeafInputField<HashMap<Integer, String>>();
	private final LeafInputField<Date> inputConsultaMarcacaoData = new LeafInputField<Date>();

	// email marcacao consulta
	private final JLabel labelConsultaMarcacaoEmailData = new JLabel( "Data" );
	private final JLabel labelConsultaMarcacaoEmailSubject = new JLabel( "Assunto" );
	private final JLabel labelConsultaMarcacaoEmailBody = new JLabel( "Mensagem" );

	private final LeafInputField<Date> inputConsultaMarcacaoEmailData = new LeafInputField<Date>();
	private final LeafInputField<String> inputConsultaMarcacaoEmailSubject = new LeafInputField<String>();
	private final LeafInputField<String> inputConsultaMarcacaoEmailBody = new LeafInputField<String>();

	// observacao marcacao consulta
	private final LeafInputField<String> inputConsultaMarcacaoObsMensagem = new LeafInputField<String>();

	// exame
	private final JLabel labelExameEstado = new JLabel( "Estado" );
	private final JLabel labelExameData = new JLabel( "Data" );

	private final LeafInputField<String> inputExameEstado = new LeafInputField<String>();
	private final LeafInputField<Date> inputExameData = new LeafInputField<Date>();

	// marcacao exame
	private final JLabel labelExameMarcacaoEstado = new JLabel( "Estado" );
	private final JLabel labelExameMarcacaoData = new JLabel( "Data" );

	private final LeafInputField<String> inputExameMarcacaoEstado = new LeafInputField<String>();
	private final LeafInputField<Date> inputExameMarcacaoData = new LeafInputField<Date>();

	// email marcacao exame
	private final JLabel labelExameMarcacaoEmailData = new JLabel( "Data" );
	private final JLabel labelExameMarcacaoEmailSubject = new JLabel( "Assunto" );
	private final JLabel labelExameMarcacaoEmailBody = new JLabel( "Mensagem" );

	private final LeafInputField<Date> inputExameMarcacaoEmailData = new LeafInputField<Date>();
	private final LeafInputField<String> inputExameMarcacaoEmailSubject = new LeafInputField<String>();
	private final LeafInputField<String> inputExameMarcacaoEmailBody = new LeafInputField<String>();

	// observacao marcacao exame
	private final LeafInputField<String> inputExameMarcacaoObsMensagem = new LeafInputField<String>();

	public ProcessoDadosPanel(SIPRPWindow parentWindow)
	{
		this.parentWindow = parentWindow;
		setupLayout();
		setupComponents();
		placeComponents();
	}

	private void setupLayout()
	{
		this.setLayout( cardLayout );
	}

	private void setupComponents()
	{
		setupStartPanel();
		setupTrabalhadorPanel();
		setupProcessoPanel();
		setupConsultaPanel();
		setupConsultaMarcacaoPanel();
		setupConsultaMarcacaoEmailPanel();
		setupConsultaMarcacaoObservacoesPanel();
		setupExamePanel();
		setupExameMarcacaoPanel();
		setupExameMarcacaoEmailPanel();
		setupExameMarcacaoObservacoesPanel();
	}

	private void placeComponents()
	{
		add( panelStart, PANEL_START_NAME );
		add( panelTrabalhador, PANEL_TRABALHADOR_NAME );
		add( panelProcesso, PANEL_PROCESSO_NAME );
		add( panelConsulta, PANEL_CONSULTA_NAME );
		add( panelConsultaMarcacao, PANEL_CONSULTA_MARCACAO_NAME );
		add( panelConsultaMarcacaoEmail, PANEL_CONSULTA_MARCACAO_EMAIL_NAME );
		add( panelConsultaMarcacaoObservacao, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME );
		add( panelExame, PANEL_EXAME_NAME );
		add( panelExameMarcacao, PANEL_EXAME_MARCACAO_NAME );
		add( panelExameMarcacaoEmail, PANEL_EXAME_MARCACAO_EMAIL_NAME );
		add( panelExameMarcacaoObservacao, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME );
	}

	@LeafUIActionBinding(action = { LOAD_TRABALHADOR, SELECT_TRABALHADOR })
	public void setForTrabalhador( Trabalhadores trabalhador )
	{
		if( trabalhador != null )
		{
			inputTrabalhadorDataNascimento.setObject( trabalhador.getDataNascimento() );
			inputTrabalhadorSexo.setObject( trabalhador.getSexos() );
			inputTrabalhadorSexo.setSelectedObject( trabalhador.getSexo() );
			inputTrabalhadorNome.setObject( trabalhador.getNome() );
			inputTrabalhadorNacionalidade.setObject( trabalhador.getNacionalidade() );
			inputTrabalhadorObservacoes.setObject( trabalhador.getObservacoes() );

			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_START_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_PROCESSO)
	public void setForProcesso( TrabalhadoresProcesso processo )
	{
		if( processo != null )
		{
			inputProcessoDataFim.setObject( processo.getDataFim() );
			inputProcessoDataInicio.setObject( processo.getDataInicio() );
			inputProcessoEstado.setObject( processo.getEstados() );
			inputProcessoEstado.setSelectedObject( processo.getEstado()  );
			inputProcessoMotivo.setObject( processo.getMotivos() );
			inputProcessoMotivo.setSelectedObject( processo.getMotivo()  );

			cardLayout.show( this, PANEL_PROCESSO_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_CONSULTA)
	public void setForConsulta( TrabalhadoresConsultas consulta )
	{
		if( consulta != null )
		{
			inputConsultaEstado.setObject( consulta.getConsultaEstados() );
			inputConsultaEstado.setSelectedObject( consulta.getEstado() );
			inputConsultaData.setObject( consulta.getData() == null ? new Date( 0 ) : consulta.getData() );

			// inputConsultaData.setError( consulta.getData() == null ||
			// consulta.getData().equals( new Date(0) ) );

			cardLayout.show( this, PANEL_CONSULTA_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO)
	public void setForConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
	{
		if( marcacao != null )
		{
			inputConsultaMarcacaoData.setObject( marcacao.getData() );
			inputConsultaMarcacaoEstado.setObject( marcacao.getConsultaEstados() );
			inputConsultaMarcacaoEstado.setSelectedObject( marcacao.getEstado() );
			cardLayout.show( this, PANEL_CONSULTA_MARCACAO_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_EMAIL)
	public void setForConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
	{
		if( email != null )
		{
			inputConsultaMarcacaoEmailBody.setObject( email.getBody() );
			inputConsultaMarcacaoEmailSubject.setObject( email.getSubject() );
			inputConsultaMarcacaoEmailData.setObject( email.getData() );
			cardLayout.show( this, PANEL_CONSULTA_MARCACAO_EMAIL_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_CONSULTA_MARCACAO_OBSERVACAO)
	public void setForConsultaMarcacaoObs( TrabalhadoresConsultasDatasObservacoes obs )
	{
		if( obs != null )
		{
			inputConsultaMarcacaoObsMensagem.setEditable( true );
			inputConsultaMarcacaoObsMensagem.setObject( obs.getObservacao() == null ? "" : obs.getObservacao() );
			cardLayout.show( this, PANEL_CONSULTA_MARCACAO_OBSERVACOES_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_EXAME)
	public void setForExame( TrabalhadoresEcds exame )
	{
		if( exame != null )
		{
			inputExameData.setObject( exame.getData() );
			inputExameEstado.setObject( exame.getEstadoString() );
			cardLayout.show( this, PANEL_EXAME_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO)
	public void setForExameMarcacao( TrabalhadoresEcdsDatas exameMarcacao )
	{
		if( exameMarcacao != null )
		{
			inputExameMarcacaoData.setObject( exameMarcacao.getData() );
			inputExameMarcacaoEstado.setObject( exameMarcacao.getEstadoString() );
			cardLayout.show( this, PANEL_EXAME_MARCACAO_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_EMAIL)
	public void setForExameMarcacaoEmail( TrabalhadoresEcdsDatasEmails email )
	{
		if( email != null )
		{
			inputExameMarcacaoEmailBody.setObject( email.getBody() );
			inputExameMarcacaoEmailSubject.setObject( email.getSubject() );
			inputExameMarcacaoEmailData.setObject( email.getData() );
			cardLayout.show( this, PANEL_EXAME_MARCACAO_EMAIL_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = SELECT_EXAME_MARCACAO_OBSERVACAO)
	public void setForExameMarcacaoObs( TrabalhadoresEcdsDatasObservacoes obs )
	{
		if( obs != null )
		{
			inputExameMarcacaoObsMensagem.setObject( obs.getObservacao() == null ? "" : obs.getObservacao() );
			cardLayout.show( this, PANEL_EXAME_MARCACAO_OBSERVACAO_NAME );
		}
		else
		{
			cardLayout.show( this, PANEL_TRABALHADOR_NAME );
		}
	}

	@LeafUIActionBinding(action = CREATE_CONSULTA)
	public void setForNewConsulta( TrabalhadoresConsultas consulta )
	{
		inputConsultaData.setEditable( true );
	}

	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO)
	public void setForNewConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
	{
		LeafCalendarDialog calendar = new LeafCalendarDialog( getParentFrame(), this, false );
		Date date = calendar.getDate();
		marcacao.setData( date );
	}

	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_EMAIL)
	public void setForNewConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
	{
		inputConsultaMarcacaoEmailBody.setEditable( true );
		inputConsultaMarcacaoEmailData.setEditable( true );
		inputConsultaMarcacaoEmailSubject.setEditable( true );
	}

	@LeafUIActionBinding(action = CREATE_CONSULTA_MARCACAO_OBSERVACOES)
	public void setForNewConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes observacoes )
	{
		inputConsultaMarcacaoObsMensagem.setEditable( true );
	}

	@LeafUIActionBinding(action = SAVE_CONSULTA)
	public void updateToSaveConsulta( TrabalhadoresConsultas consulta )
	{
		consulta.setData( inputConsultaData.getObject() );
		consulta.setEstado( (Integer) inputConsultaEstado.getSelectedObject() );
	}

	@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO)
	public void updateToSaveConsultaMarcacao( TrabalhadoresConsultasDatas marcacao )
	{
		marcacao.setData( inputConsultaMarcacaoData.getObject() );
		marcacao.setEstado( (Integer) inputConsultaMarcacaoEstado.getSelectedObject() );
	}

	@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_EMAIL)
	public void updateToSaveConsultaMarcacaoEmail( TrabalhadoresConsultasDatasEmails email )
	{
		email.setBody( inputConsultaMarcacaoEmailBody.getText() );
		email.setData( inputConsultaMarcacaoEmailData.getObject() );
		email.setSubject( inputConsultaMarcacaoEmailSubject.getText() );
	}

	@LeafUIActionBinding(action = SAVE_CONSULTA_MARCACAO_OBSERVACOES)
	public void updateToSaveConsultaMarcacaoObservacoes( TrabalhadoresConsultasDatasObservacoes observacoes )
	{
		observacoes.setObservacao( inputConsultaMarcacaoObsMensagem.getText() );
	}

	@LeafUIActionBinding(action = CREATE_EXAME)
	public void setForNewExame( TrabalhadoresEcds exame )
	{
		inputExameData.setEditable( true );
		inputExameEstado.setEditable( true );
	}

	private void setupStartPanel()
	{
	}

	private void setupSimpleDataPanel( JPanel panel, String name, JComponent... field )
	{
		double[] cols = new double[] {
			FILL
		};
		double[] rows = new double[field.length];
		for( int i = 0; i < field.length; rows[i++] = MINIMUM )
			;
		rows[rows.length - 1] = FILL;
		TableLayout layout = new TableLayout( cols, rows );
		layout.setHGap( 5 );
		layout.setVGap( 5 );
		panel.setLayout( layout );
		if( name != null )
		{
			panel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), name ) );
		}

		for( int i = 0; i < field.length; ++i )
		{
			panel.add( field[i], new TableLayoutConstraints( 0, i ) );
		}
	}

	private void setupTrabalhadorPanel()
	{
		inputTrabalhadorNacionalidade.setEditable( false );
		inputTrabalhadorDataNascimento.setEditable( false );
		inputTrabalhadorNome.setEditable( false );
		inputTrabalhadorSexo.setEditable( false );
		inputTrabalhadorObservacoes.setEditable( false );
		setupSimpleDataPanel( panelTrabalhador, "Trabalhador", labelTrabalhadorNome, inputTrabalhadorNome, labelTrabalhadorSexo, inputTrabalhadorSexo, labelTrabalhadorNacionalidade, inputTrabalhadorNacionalidade, labelTrabalhadorDataNascimento, inputTrabalhadorDataNascimento, labelTrabalhadorObservacoes, inputTrabalhadorObservacoes );
	}

	private void setupProcessoPanel()
	{
		setupSimpleDataPanel( panelProcesso, "Processo", labelProcessoEstado, inputProcessoEstado, labelProcessoDataInicio, inputProcessoDataInicio, labelProcessoDataFim, inputProcessoDataFim, labelProcessoMotivo, inputProcessoMotivo, new JPanel() );
	}

	private void setupConsultaPanel()
	{
		setupSimpleDataPanel( panelConsulta, "Consulta", labelConsultaEstado, inputConsultaEstado, labelConsultaData, inputConsultaData, new JPanel() );
		inputConsultaEstado.setEditable( true );
		inputConsultaData.setEditable( true );
	}

	private void setupConsultaMarcacaoPanel()
	{
		setupSimpleDataPanel( panelConsultaMarcacao, "Marca" + ccedil + atilde + "o de Consulta", labelConsultaMarcacaoEstado, inputConsultaMarcacaoEstado, labelConsultaMarcacaoData, inputConsultaMarcacaoData, new JPanel() );
	}

	private void setupConsultaMarcacaoEmailPanel()
	{
		setupSimpleDataPanel( panelConsultaMarcacaoEmail, "Email", labelConsultaMarcacaoEmailData, inputConsultaMarcacaoEmailData, labelConsultaMarcacaoEmailSubject, inputConsultaMarcacaoEmailSubject, labelConsultaMarcacaoEmailBody, inputConsultaMarcacaoEmailBody );
	}

	private void setupConsultaMarcacaoObservacoesPanel()
	{
		inputConsultaMarcacaoObsMensagem.setEditable( false );
		setupSimpleDataPanel( panelConsultaMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputConsultaMarcacaoObsMensagem );
	}

	private void setupExamePanel()
	{
		setupSimpleDataPanel( panelExame, "Exame", labelExameEstado, inputExameEstado, labelExameData, inputExameData, new JPanel() );
	}

	private void setupExameMarcacaoPanel()
	{
		setupSimpleDataPanel( panelExameMarcacao, "Marca" + ccedil + atilde + "o de Exame", labelExameMarcacaoEstado, inputExameMarcacaoEstado, labelExameMarcacaoData, inputExameMarcacaoData, new JPanel() );
	}

	private void setupExameMarcacaoEmailPanel()
	{
		setupSimpleDataPanel( panelExameMarcacaoEmail, "Email", labelExameMarcacaoEmailData, inputExameMarcacaoEmailData, labelExameMarcacaoEmailSubject, inputExameMarcacaoEmailSubject, labelExameMarcacaoEmailBody, inputExameMarcacaoEmailBody );
	}

	private void setupExameMarcacaoObservacoesPanel()
	{
		inputExameMarcacaoObsMensagem.setEditable( false );
		setupSimpleDataPanel( panelExameMarcacaoObservacao, "Observa" + ccedil + otilde + "es", inputExameMarcacaoObsMensagem );
	}

	private JFrame getParentFrame()
	{
		if( getRootPane() != null && getRootPane().getParent() instanceof JFrame )
		{
			return (JFrame) getRootPane().getParent();
		}
		return null;
	}
}
