Package clips.doctor.diagnosis

Source Code of clips.doctor.diagnosis.PanelDiagnosisList

/*
* PanelCertificateList.java
*
* Created on 1 Апрель 2008 г., 12:02
*/

package clips.doctor.diagnosis;

import clips.delegate.client.ClientLocal;
import clips.delegate.doctor.diagnosis.DiagnosisLocal;
import cli_fmw.delegate.DelegateLine2;
import clips.doctor.PanelEMC;
import cli_fmw.main.ClipsException;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.Printable;
import cli_fmw.report.FormReportCreator;
import cli_fmw.report.ReporterFactory;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.table_config_states.StateSaver;
import cli_fmw.utils.table_config_states.TableState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import javax.swing.ListSelectionModel;

/**
* Панель отображающая список анализов пациента (исключая сопутствующие)
* @author  vip
*/
public class PanelDiagnosisList extends PageGeneric implements Printable {
    ClientLocal clientLocal;
    private ArrayList<DiagnosisLocal> diagnosisLocals;
   
    /** Creates new form PanelCertificateList */
    public PanelDiagnosisList(PageContainer container, ClientLocal clientLocal) throws ClipsException {
        super(container);
        initComponents();
        this.clientLocal = clientLocal;
        reloadTable();
    resizeColumn();
    StateSaver.attachTo(this);
    }

    private void reloadTable() throws ClipsException {
        diagnosisLocals = (ArrayList<DiagnosisLocal>) clientLocal.getDiagnosisList();
       
        jTable.setModel(new TableModelDiagnosisList(diagnosisLocals));
        jTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     }

    private void resizeColumn() {
     TableState          state = new TableState();
    state.setPreferredWidth(TableModelDiagnosisList.COL_DATE,    4);
        state.setPreferredWidth(TableModelDiagnosisList.COL_MKB_CODE,   4);
    state.setPreferredWidth(TableModelDiagnosisList.COL_MKB,    14);
    state.setPreferredWidth(TableModelDiagnosisList.COL_TYPE,    8);
    state.setPreferredWidth(TableModelDiagnosisList.COL_ENCOUNTER,  8);
    state.setPreferredWidth(TableModelDiagnosisList.COL_STAGE,    2);
      StateSaver.setDefaultState(this, jTable, state);
    }
   
   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable = new cli_fmw.utils.sorted_table.SortedTable();

        setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        setLayout(new java.awt.BorderLayout());

        jScrollPane1.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                jScrollPane1ComponentResized(evt);
            }
        });

        jTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable);

        add(jScrollPane1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

private void jTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableMouseClicked
    int row = jTable.getSelectedRowSorted();   
    if (evt.getClickCount() == 2 && row > -1) {           
        if (row >=0 ) {
            DiagnosisLocal d = diagnosisLocals.get(row);
            if (getContainer() instanceof PanelEMC) {
                try {
                    ((PanelEMC) getContainer()).selectInEmc(d);
                } catch (ClipsException ex) {
                    ex.printStackTrace();
                    MessageBox.showException(ex);
                }
            }
        }
    }
}//GEN-LAST:event_jTableMouseClicked

private void jScrollPane1ComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jScrollPane1ComponentResized

}//GEN-LAST:event_jScrollPane1ComponentResized
   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private cli_fmw.utils.sorted_table.SortedTable jTable;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Список диагнозов";
    }

    public String getPageIcon() {
        return null;
    }

    @Override
    public boolean readyForPrint() {
        return true;
    }

    @Override
    public void print() {
        if (readyForPrint()) {
            FormReportCreator creater = ReporterFactory.createFormReporter(getClass());
            HashMap<String, Object> data = new LinkedHashMap<String, Object>();
            String title = "Список диагнозов пациента";
            data.put("client", "Пациент: " + clientLocal.toString());
            creater.createReport(title, null, data.entrySet(), jTable.getModel());
            creater.finish();
        }
    }

    @Override
    public DelegateLine2 getDelegate() {
        return clientLocal;
    }
   
}
TOP

Related Classes of clips.doctor.diagnosis.PanelDiagnosisList

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.