Package clips.analysis

Source Code of clips.analysis.PanelAnalysesFactoryList

/*
* PanelAnalysesFactoryList.java
*
* Created on 22 Декабрь 2007 г., 13:36
*/

package clips.analysis;

import clips.analysis.individual.DialogRenderAnalyseIndividual;
import clips.analysis.takeSample.DialogTakeSample;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.main.PageContainer;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.delegate.utils.TimeLocal;
import clips.delegate.directory.complex.DirectoryLaboratoryItem;
import clips.delegate.directory.filtered.DirectoryServiceItem;
import clips.delegate.doctor.checkup.CheckupFactoryLocal;
import clips.delegate.doctor.checkup.CheckupLocal;
import clips.directory.dialogs.DirectoryDialogService;
import cli_fmw.main.ClipsException;
import cli_fmw.main.ContentStateListener;
import cli_fmw.main.MainWindow;
import cli_fmw.main.PrintCreators;
import cli_fmw.main.Printable;
import cli_fmw.main.PageGeneric;
import cli_fmw.report.CombinedReportCreator;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.Selector;
import cli_fmw.utils.table_config_states.StateSaver;
import cli_fmw.utils.table_config_states.TableState;
import clips.delegate.directory.complex.DirectoryLaboratory;
import clips.login.UserInfo;
import framework.utils.ROList;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
* Рабочее место медсестры по забору биоматериала. Панель отображает пациентов, у которых
* не погашены услуги по забору биоматериала.
* @author  Администратор
*/
public class PanelAnalysesFactoryList extends PageGeneric implements Printable {
    private ArrayList<CheckupLocal> checkupList;
    private CheckupLocal selectedCheckup;
    private DirectoryServiceItem selectedService;
    private CheckupFactoryLocal cfl;
    private ContentStateListener emptyListener = new ContentStateListener() {
        @Override
        public void contentStateChanged() {
            //DO NOTHING
        }
    };
    /** Creates new form PanelAnalysesFactoryList
     * @param container
     * @throws ClipsException
     */
    public PanelAnalysesFactoryList(PageContainer container) throws ClipsException {
        super(container);
        initComponents();
        cfl = new CheckupFactoryLocal(getAuditManager());
        //заполнение комбо
       
        DirectoryLaboratory dirLab = DirectoryLocator.getDirectory(DirectoryLaboratory.class);
    ROList<DirectoryLaboratoryItem> list = dirLab.getFilteredItems(UserInfo.get().getCollaborator().getLpu());
        jComboBox1.setModel(new DefaultComboBoxModel(dirLab.toArray()));
        jTable1.setModel(new TableModelAnalyseList(new ArrayList<CheckupLocal>()));
        jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (jTable1.getSelectedRowSorted() >= 0) {
                    selectedCheckup = checkupList.get(jTable1.getSelectedRowSorted());
                } else {
                    selectedCheckup = null;
                }
                fireContainerEventStateChanged();
                setEnabledComponents();
            }
        });
        //set default period
        GregorianCalendar gc = TimeLocal.getCurrentTime();
        dateTo.setDate(gc.getTime());
        gc.add(GregorianCalendar.MONTH, -1);
        dateFrom.setDate(gc.getTime());
    resizeColumn();
        StateSaver.attachTo(this);
    }
   
    private void setEnabledComponents() {
        btProbe.setEnabled(selectedCheckup != null);
        btAnalyse.setEnabled(selectedCheckup != null);
    }
   
    /** 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() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel3 = new javax.swing.JPanel();
        jPanelNorth = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jPanel5 = new javax.swing.JPanel();
        jPanelService = new javax.swing.JPanel();
        cbOnlyService = new javax.swing.JCheckBox();
        jPanel6 = new javax.swing.JPanel();
        tfService = new javax.swing.JTextField();
        btService = new javax.swing.JButton();
        rbRendered = new javax.swing.JRadioButton();
        rbNotRendered = new javax.swing.JRadioButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        dateFrom = new org.infotechservice.ICalendar.components.ICDateChooser();
        jLabel2 = new javax.swing.JLabel();
        dateTo = new org.infotechservice.ICalendar.components.ICDateChooser();
        btSearch = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        btProbe = new javax.swing.JButton();
        btAnalyse = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new cli_fmw.utils.sorted_table.SortedTable();

        jPanel3.setLayout(new java.awt.BorderLayout());

        jLabel1.setText("Лаборатория:");

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Фильтр"));
        jPanel5.setLayout(new java.awt.GridLayout(0, 1));

        cbOnlyService.setText("Только услуга:");
        cbOnlyService.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbOnlyServiceActionPerformed(evt);
            }
        });

        jPanel6.setLayout(new java.awt.BorderLayout(5, 0));

        tfService.setEditable(false);
        jPanel6.add(tfService, java.awt.BorderLayout.CENTER);

        btService.setText("...");
        btService.setEnabled(false);
        btService.setPreferredSize(new java.awt.Dimension(20, 20));
        btService.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btServiceActionPerformed(evt);
            }
        });
        jPanel6.add(btService, java.awt.BorderLayout.EAST);

        javax.swing.GroupLayout jPanelServiceLayout = new javax.swing.GroupLayout(jPanelService);
        jPanelService.setLayout(jPanelServiceLayout);
        jPanelServiceLayout.setHorizontalGroup(
            jPanelServiceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelServiceLayout.createSequentialGroup()
                .addComponent(cbOnlyService)
                .addGap(10, 10, 10)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelServiceLayout.setVerticalGroup(
            jPanelServiceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelServiceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                .addComponent(cbOnlyService, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.add(jPanelService);

        buttonGroup1.add(rbRendered);
        rbRendered.setText("Показывать выполненные");
        jPanel5.add(rbRendered);

        buttonGroup1.add(rbNotRendered);
        rbNotRendered.setSelected(true);
        rbNotRendered.setText("Показывать не выполненные");
        jPanel5.add(rbNotRendered);

        jPanel8.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jLabel3.setText("Дата назначения с");
        jPanel8.add(jLabel3);

        dateFrom.setPreferredSize(new java.awt.Dimension(124, 27));
        jPanel8.add(dateFrom);

        jLabel2.setText("по");
        jPanel8.add(jLabel2);

        dateTo.setPreferredSize(new java.awt.Dimension(124, 27));
        jPanel8.add(dateTo);

        jPanel5.add(jPanel8);

        btSearch.setText("Найти");
        btSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
                    .addComponent(btSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox1, 0, 443, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btSearch)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanelNorthLayout = new javax.swing.GroupLayout(jPanelNorth);
        jPanelNorth.setLayout(jPanelNorthLayout);
        jPanelNorthLayout.setHorizontalGroup(
            jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelNorthLayout.createSequentialGroup()
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(150, Short.MAX_VALUE))
        );
        jPanelNorthLayout.setVerticalGroup(
            jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jPanel3.add(jPanelNorth, java.awt.BorderLayout.NORTH);

        jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        btProbe.setText("    Пробы    ");
        btProbe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btProbeActionPerformed(evt);
            }
        });
        jPanel4.add(btProbe);

        btAnalyse.setText("Результат");
        btAnalyse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAnalyseActionPerformed(evt);
            }
        });
        jPanel4.add(btAnalyse);

        jPanel3.add(jPanel4, java.awt.BorderLayout.SOUTH);

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

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

        jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 617, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btProbeActionPerformed(java.awt.event.ActionEvent evt) {                                           
        if (jTable1.getSelectedRowCount() > 0) {
            CheckupLocal checkUp = checkupList.get(jTable1.getSelectedRowSorted());
            try {
                checkUp.addContentStateListener(emptyListener);
                checkUp.getSerrenLocal().addContentStateListener(emptyListener);
                DialogTakeSample dialog = new DialogTakeSample(MainWindow.mainWindow, checkUp, getAuditManager());
                dialog.setVisible(true);
                jTable1.updateUI();
            } catch (ClipsException ex) {
                MessageBox.showException(ex);
            }
        }
}
   
    private void resizeColumn() {
    TableState          state = new TableState();
    state.setPreferredWidth(TableModelAnalyseList.COL_FIO,      4);
    state.setPreferredWidth(TableModelAnalyseList.COL_SERVICE,    7);
    state.setPreferredWidth(TableModelAnalyseList.COL_DATE,      2);
    state.setPreferredWidth(TableModelAnalyseList.COL_PAYED,    2);
    state.setPreferredWidth(TableModelAnalyseList.COL_PROBE_DATE,  2);
    state.setPreferredWidth(TableModelAnalyseList.COL_RENDERED_DATE,2);
    state.setPreferredWidth(TableModelAnalyseList.COL_PROBE,    3);
      StateSaver.setDefaultState(this, jTable1, state);
    }

private void btSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSearchActionPerformed
        reloadFromServer();
}//GEN-LAST:event_btSearchActionPerformed

private void cbOnlyServiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbOnlyServiceActionPerformed
        if (cbOnlyService.isSelected()) {
            btService.setEnabled(true);
        } else {
            btService.setEnabled(false);
        }
}//GEN-LAST:event_cbOnlyServiceActionPerformed

private void btServiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btServiceActionPerformed
        try {
            DirectoryDialogService dds = new DirectoryDialogService(false, selectedService);
            dds.setVisible(true);
            if (dds.getDlgResult() == DirectoryDialogService.DLG_OK) {
                Selector ii = dds.getSelectedItems();
                if (ii.size() > 0) {
                    DirectoryServiceItem item = (DirectoryServiceItem) ii.get(0);
                    tfService.setText(item.toString());
                    selectedService = item;
                }
            }
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
}//GEN-LAST:event_btServiceActionPerformed

private void btAnalyseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAnalyseActionPerformed
        if (jTable1.getSelectedRowCount() > 0) {
            CheckupLocal checkUp = checkupList.get(jTable1.getSelectedRowSorted());
            try {
                checkUp.addContentStateListener(emptyListener);
                checkUp.getSerrenLocal().addContentStateListener(emptyListener);
                DialogRenderAnalyseIndividual dialog = new DialogRenderAnalyseIndividual(MainWindow.mainWindow, checkUp, getAuditManager());
                dialog.setVisible(true);
                jTable1.updateUI();
            } catch (ClipsException ex) {
                MessageBox.showException(ex);
            }
        }
}//GEN-LAST:event_btAnalyseActionPerformed

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        if (evt.getClickCount() == 2) {
            if (jTable1.getSelectedRowCount() > 0) {
                CheckupLocal checkUp = checkupList.get(jTable1.getSelectedRowSorted());
                try {
                    checkUp.addContentStateListener(emptyListener);
                    checkUp.getSerrenLocal().addContentStateListener(emptyListener);
                    DialogTakeSample dialog = new DialogTakeSample(MainWindow.mainWindow, checkUp, getAuditManager());
                    dialog.setVisible(true);
                    jTable1.updateUI();
                } catch (ClipsException ex) {
                    MessageBox.showException(ex);
                }
            }
        }
}//GEN-LAST:event_jTable1MouseClicked

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

    /**
     * Обновление списка чекапов (с сервера)
     */
    private void reloadFromServer() {                                            
        DirectoryLaboratoryItem laboratory = (DirectoryLaboratoryItem) jComboBox1.getSelectedItem();
        DirectoryServiceItem service = null;
        if (cbOnlyService.isSelected()) {
            service = selectedService;
        }
        boolean rendered = rbRendered.isSelected();
        Date from = dateFrom.getDate();
        Date to = dateTo.getDate();
        try {
            /*Находим чекапы по запросу к базе
             * Выборка делается по запросу найти чекапы у которых тип соответствует лаборатории
             * выборка идет либо по определенной услуге либо по всем услугам
             * выборка идет либо по оказанным услугам либо по неоказанным
             */
            checkupList = cfl.getAnalyseList(laboratory, service, rendered, from, to);
            jTable1.setModel(new TableModelAnalyseList(checkupList));
            jTable1.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            fireContainerEventStateChanged();
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
    }
    }
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAnalyse;
    private javax.swing.JButton btProbe;
    private javax.swing.JButton btSearch;
    private javax.swing.JButton btService;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JCheckBox cbOnlyService;
    private org.infotechservice.ICalendar.components.ICDateChooser dateFrom;
    private org.infotechservice.ICalendar.components.ICDateChooser dateTo;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanelNorth;
    private javax.swing.JPanel jPanelService;
    private javax.swing.JScrollPane jScrollPane1;
    private cli_fmw.utils.sorted_table.SortedTable jTable1;
    private javax.swing.JRadioButton rbNotRendered;
    private javax.swing.JRadioButton rbRendered;
    private javax.swing.JTextField tfService;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Поиск анализов";
    }

    @Override
    public boolean readyForPrint() {
        return selectedCheckup != null;
    }

    @Override
    public void print() {
        if (readyForPrint()) {
            try {
                CombinedReportCreator parCreator = PrintCreators.createCombinedReportHeader(getClass());
               
                selectedCheckup.print(parCreator);               
                parCreator.finish();
            } catch (ClipsException ex) {
                MessageBox.showException(ex);
            }
        }
    }

    @Override
    public DelegateLine2 getDelegate() {
        return selectedCheckup;
    }

}
TOP

Related Classes of clips.analysis.PanelAnalysesFactoryList

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.