Package clips.doctor.disease

Source Code of clips.doctor.disease.PanelDiseaseStatus

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* PanelDiseaseStatus.java
*
* Created on 08.05.2009, 12:14:22
*/

package clips.doctor.disease;

import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.main.ClipsException;
import cli_fmw.main.MainWindow;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.Persistentable;
import cli_fmw.report.panels.model.delegate.DirectoryComboBoxModel;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import clips.delegate.directory.ro.DirectoryCollaborator;
import clips.delegate.directory.simple.diseaseResult.DirectoryDiseaseResult;
import clips.delegate.directory.simple.visitingPurpose.DirectoryVisitingPurpose;
import clips.delegate.directory.simple.visitingPurpose.DirectoryVisitingPurposeItem;
import clips.delegate.doctor.DiseaseLocal;
import clips.login.UserInfo;
import framework.utils.Converter;

/**
*
* @author vip
*/
public class PanelDiseaseStatus extends PageGeneric implements Persistentable {

    private DiseaseLocal diseaseLocal;
    DirectoryCollaborator directoryCollaborator;

    public PanelDiseaseStatus(PageContainer container, final DiseaseLocal diseaseLocal) throws ClipsException {
        super(container);
        initComponents();
        this.diseaseLocal = diseaseLocal;

        DirectoryVisitingPurpose purpose = DirectoryLocator.getDirectory(DirectoryVisitingPurpose.class);
        directoryCollaborator = DirectoryLocator.getDirectory(DirectoryCollaborator.class);
        setScreenFields();
        StateSaver.attachTo(this);
    }

    private void setScreenFields() throws ClipsException {
        if (diseaseLocal.getClosed() != null && diseaseLocal.getCloser() == null) {
            throw new ClipsException("В базу данных внесены некорректные данные, заболевание [ id: " + diseaseLocal.getID() + "] \n" +
                    "записано как закрытое, но не указан закрывший его сотрудник");
        }
        if (diseaseLocal.getClosed() != null) {
            lbStatus.setText("закрыто "
                    + Converter.dateToString(diseaseLocal.getClosed())
                    + ", " + diseaseLocal.getCloser().getTitle());
            btClose.setText("Открыть");
            btClose.setVisible(UserInfo.get().isSuperUser());
        } else {
            lbStatus.setText("открыто");
            btClose.setText("Закрыть");
        }


        lbCreated.setText(Converter.dateToString(diseaseLocal.getCreated())
                + ", " + diseaseLocal.getCollaborator().getTitle());
        lbDiagnosys.setText((diseaseLocal.getSpecificDiagnosis() == null
                    ? "не указан"
                    : diseaseLocal.getSpecificDiagnosis().getMkbAndStage()));
        lbResult.setText((diseaseLocal.getDiseaseResult() == null
                    ? "не указан"
                    : diseaseLocal.getDiseaseResult().getTitle()));
        lblPurpose.setText((diseaseLocal.getVisitingPurpose() == null
                    ? "не указан"
                    : diseaseLocal.getVisitingPurpose().getTitle()));

    }

    /** 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        titles = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        values = new javax.swing.JPanel();
        lbStatus = new javax.swing.JLabel();
        lbCreated = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        lbDiagnosys = new javax.swing.JLabel();
        lbResult = new javax.swing.JLabel();
        lblPurpose = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        btClose = new javax.swing.JButton();

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

        jPanel1.setLayout(new java.awt.BorderLayout(5, 10));

        titles.setLayout(new java.awt.GridLayout(0, 1, 5, 5));

        jLabel1.setText("Статус:");
        titles.add(jLabel1);

        jLabel2.setText("Создано:");
        titles.add(jLabel2);

        jLabel3.setText("Основной диагноз:");
        titles.add(jLabel3);

        jLabel4.setText("Результат посещения:");
        titles.add(jLabel4);

        jLabel5.setText("Цель посещения:");
        titles.add(jLabel5);

        jPanel1.add(titles, java.awt.BorderLayout.WEST);

        values.setLayout(new java.awt.GridLayout(0, 1, 5, 5));
        values.add(lbStatus);
        values.add(lbCreated);

        jScrollPane1.setBorder(null);
        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        jScrollPane1.setViewportView(lbDiagnosys);

        values.add(jScrollPane1);
        values.add(lbResult);

        lblPurpose.setText(" ");
        lblPurpose.setMinimumSize(new java.awt.Dimension(4, 20));
        values.add(lblPurpose);

        jPanel1.add(values, java.awt.BorderLayout.CENTER);

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

        btClose.setText("Закрыть");
        btClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCloseActionPerformed(evt);
            }
        });
        jPanel5.add(btClose, java.awt.BorderLayout.EAST);

        jPanel1.add(jPanel5, java.awt.BorderLayout.PAGE_END);

        jPanel2.add(jPanel1, java.awt.BorderLayout.NORTH);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCloseActionPerformed
        try {
            if (diseaseLocal.isNewlyCreated()){
                MessageBox.showError(MessageBox.E_CANT_CREATE_CLOSED_DISEASE);
                return;
            }
            if (diseaseLocal.getClosed() == null) {
                DialogDiseaseClose dlg = new DialogDiseaseClose(MainWindow.mainWindow, diseaseLocal, getAuditManager());
                dlg.setVisible(true);
                if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
                    diseaseLocal.save1();
                    setScreenFields();
                }
                else {
                    diseaseLocal.restore();
                }
            } else {
                diseaseLocal.setClosed(null);
                diseaseLocal.setCloser(null);
                DirectoryDiseaseResult dir = DirectoryLocator.getDirectory((DirectoryDiseaseResult.class));
                diseaseLocal.setDiseaseResult(dir.getNullItem());
                save();
                setScreenFields();
            }
        } catch (ClipsException ex) {
            diseaseLocal.restore();
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btCloseActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btClose;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lbCreated;
    private javax.swing.JLabel lbDiagnosys;
    private javax.swing.JLabel lbResult;
    private javax.swing.JLabel lbStatus;
    private javax.swing.JLabel lblPurpose;
    private javax.swing.JPanel titles;
    private javax.swing.JPanel values;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Статус заболевания";
    }

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

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

    @Override
    public void save() throws ClipsException {
        diseaseLocal.save1();
    }

    @Override
    public void restore() {
        if (!diseaseLocal.isNewlyCreated()){
            diseaseLocal.restore();
        }
        try {
            setScreenFields();
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }

}
TOP

Related Classes of clips.doctor.disease.PanelDiseaseStatus

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.