Package clips.doctor.disease

Source Code of clips.doctor.disease.PanelDisease

/*
* PanelServiceList.java
*
* Created on 21 Февраль 2008 г., 15:30
*/
package clips.doctor.disease;

import cli_fmw.delegate.DelegateLine2;
import clips.delegate.client.ClientLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.main.MainWindow;
import clips.delegate.doctor.DiseaseLocal;
import clips.delegate.service.SerRenLocal;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.Persistentable;
import cli_fmw.main.Printable;
import cli_fmw.report.CombinedReportCreator;
import cli_fmw.report.CombinedReportOptions;
import cli_fmw.report.PageOptions.PageOrentation;
import cli_fmw.report.ReporterFactory;
import clips.service.newSerRen.DialogNewSerRen;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import clips.delegate.directory.complex.DirectoryCollaboratorFunctionsItem;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;

/**
* Панель просмотра и добавления услуг клиента работником регистратуры. Содержит
* таблицу услуг. После создания панели необходимо дать панели
* клиента методом setClient(ClientLocal client)
* @author  vip
*/
public class PanelDisease extends PageGeneric implements Persistentable, Printable {
    private ClientLocal client;
    private DiseaseLocal diseaseLocal;      //Может быть null, нужен только если отображается список услуг из заболевания
    private boolean derLocated;
    private PanelDiseaseStatus panelClose;
  /**
   *
   * @param container
   * @param client
   * @param diseaseLocal
   * @throws cli_fmw.main.ClipsException
   */
  public PanelDisease(PageContainer container, ClientLocal client, DiseaseLocal diseaseLocal) throws ClipsException {
        super(container);
        initComponents();

        //Выставление режима
        //выставление клиента и заболевания
        this.client = client;
        this.diseaseLocal = diseaseLocal;
       
        panelClose = new PanelDiseaseStatus(getContainer(), diseaseLocal);
        jPanel1.add(panelClose, BorderLayout.NORTH);
        setEnabledComponents();
    StateSaver.attachTo(this);
    }

    private void setEnabledComponents() {
        try {
            List<SerRenLocal> serRenListOutofDisease = client.getSerRenListOutofDisease();
            if (diseaseLocal.isNewlyCreated()) {
                btAdd.setEnabled(false);
                btAdd.setToolTipText("Необходимо сначала сохранить заболевание");
            } else if (diseaseLocal.getClosed() != null) {
                btAdd.setEnabled(false);
                btAdd.setToolTipText("Заболевание закрыто");
            } else if (serRenListOutofDisease.size() == 0) {
                btAdd.setEnabled(false);
                btAdd.setToolTipText("У пациента нет назначенных услуг (посещений)");
            } else {
                btAdd.setEnabled(true);
                btAdd.setToolTipText("Добавить услугу (посещение) из уже назначенных пациенту");
            }
        } catch (ClipsException ex) {
            btAdd.setEnabled(false);
            btAdd.setToolTipText("Невозможно получить список назначенных услуг (посещений)");
        }
        try {
            if (diseaseLocal.isNewlyCreated()) {
                btPrescribeService.setEnabled(false);
                btPrescribeService.setToolTipText("Необходимо сначала сохранить заболевание");
            } else if (diseaseLocal.getClosed() != null) {
                btPrescribeService.setEnabled(false);
                btPrescribeService.setToolTipText("Заболевание закрыто");
            } else {
                btPrescribeService.setEnabled(true);
                btPrescribeService.setToolTipText("Назначить услугу в заболевание");
            }
        } catch (ClipsException ex) {
            btPrescribeService.setEnabled(false);
            btPrescribeService.setToolTipText("Невозможно получить информацию с сервера");
        }
    }
    /** 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() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        btPrescribeService = new javax.swing.JButton();
        btAdd = new javax.swing.JButton();

        jLabel1.setText("В заболевании");

        setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));

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

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

        btPrescribeService.setText("Назначить услугу");
        btPrescribeService.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPrescribeServiceActionPerformed(evt);
            }
        });
        jPanel6.add(btPrescribeService);

        btAdd.setText("Добавить в заболевание");
        btAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddActionPerformed(evt);
            }
        });
        jPanel6.add(btAdd);

        jPanel1.add(jPanel6, java.awt.BorderLayout.SOUTH);

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


    private void btAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddActionPerformed
        try {
            DialogAddSerren dlg = new DialogAddSerren(MainWindow.mainWindow, diseaseLocal, getAuditManager());
            dlg.setVisible(true);
            if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
                for (SerRenLocal serRenLocal : dlg.getNewSerrenList()) {
                    serRenLocal.addContentStateListener(getContainer());
                    serRenLocal.setDiseaseLocal(diseaseLocal);
                    serRenLocal.save1();
                    diseaseLocal.addChild(serRenLocal);
                }
                diseaseLocal.save1();
            }
            diseaseLocal.getEmcLocal().getClient().clearSerRenListOutofDiseaseCache();
        } catch (ClipsException ex) {
            ex.showException();
        }
        setEnabledComponents();
}//GEN-LAST:event_btAddActionPerformed

private void btPrescribeServiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPrescribeServiceActionPerformed
        try {
            DialogNewSerRen dlg = new DialogNewSerRen(MainWindow.mainWindow, diseaseLocal, getAuditManager());
            dlg.setVisible(true);
            if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
                for (SerRenLocal serRenLocal : dlg.getNewSerrenList()) {
                    serRenLocal.addContentStateListener(getContainer());
                    diseaseLocal.addChild(serRenLocal);
                }
                diseaseLocal.save1();
            }
            if (dlg.getDlgResult() == ModalDialog.DLG_NEXTRESULT) {
                DiseaseLocal diseaseMedexam = dlg.getNewDiseaseLocal();
                diseaseLocal.getEmcLocal().addChild(diseaseMedexam);
            }
        } catch (Exception ex) {
            MessageBox.showExceptionOnly(ex);
        }
        setEnabledComponents();
}//GEN-LAST:event_btPrescribeServiceActionPerformed
   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAdd;
    private javax.swing.JButton btPrescribeService;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel6;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Статталон " + client.toString();
    }

    @Override
    public boolean isDirty() {
        return diseaseLocal.isDirty();
    }

    @Override
    public void save() throws ClipsException {
        panelClose.save();
        setEnabledComponents();
    }

    @Override
    public void restore() {
        panelClose.restore();
        //reloadTable();
        //fireContainerEventStateChanged();
    }

    @Override
    public boolean readyForPrint() {
        return !isDirty();
    }
       
    @Override
    public void print() {
        try {
            if (readyForPrint()) {
                DirectoryCollaboratorFunctionsItem collab = null;
                ArrayList<DirectoryCollaboratorFunctionsItem> collabs = diseaseLocal.getCollabsIn();
                if (collabs.isEmpty()) {
                    JOptionPane.showMessageDialog(this, "В заболевании нет оказанных услуг");
                    return;
                }
                if (collabs.size() > 1) {
                    DirectoryCollaboratorFunctionsItem[] a = new DirectoryCollaboratorFunctionsItem[collabs.size()];
                    a = collabs.toArray(a);
                    collab =
                        (DirectoryCollaboratorFunctionsItem) JOptionPane.showInputDialog(this,
                        "В заболевании несколько ТАПов.\nВыберите сотрудника (специальность), по которому печатать ТАП.",
                        "Выберите сотрудника", JOptionPane.PLAIN_MESSAGE, null, a, null);
                    if (collab == null) {
                        return;
                    }
                }
                else {
                    collab = collabs.get(0);
                }
                CombinedReportCreator parCreator = ReporterFactory.createCombinedReporter(getClass(), 1);
                CombinedReportOptions ops = new CombinedReportOptions();
                ops.topMargin =0;
                ops.bottomMargin = 0;
                ops.leftMargin =0;
                ops.rightMargin = 0;
                ops.setPageA5();
                ops.setOrentation(PageOrentation.horizontal);
                parCreator.setUpReport(null, ops, null);

                diseaseLocal.formPrintFields(collab);
                diseaseLocal.print(parCreator);
                parCreator.finish();
               
            }
        }catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }

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

Related Classes of clips.doctor.disease.PanelDisease

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.