userinterface.PatientRole.PatientAppointmentsJPanel.java Source code

Java tutorial

Introduction

Here is the source code for userinterface.PatientRole.PatientAppointmentsJPanel.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package userinterface.PatientRole;

import Business.EcoSystem;
import Business.Enterprise.Enterprise;
import Business.IndividualUser.Patient;
import Business.Organization.DoctorOrganization;
import Business.Organization.Organization;
import Business.Organization.PatientOrganization;
import Business.UserAccount.UserAccount;
import Business.VitalSigns.VitalSign;
import Business.WorkQueue.AppointmentWorkRequest;
import Business.WorkQueue.GetDiagnosisWorkRequest;
import Business.WorkQueue.WorkRequest;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;

/**
 *
 * @author Ankit Bhayani
 */
public class PatientAppointmentsJPanel extends javax.swing.JPanel {

    /**
     * Creates new form MedicalAdviceJPanel
     */
    private JPanel userProcessContainer;
    private UserAccount userAccount;
    //private Donor donor;
    private PatientOrganization patientOrganization;
    private Enterprise enterprise;
    private EcoSystem ecoSystem;
    private Patient patient;
    private DoctorOrganization doctorOrganization;

    public PatientAppointmentsJPanel(JPanel pnl, UserAccount ua, Organization o, Enterprise e, EcoSystem es) {
        initComponents();
        this.userProcessContainer = pnl;
        this.userAccount = ua;
        this.patientOrganization = (PatientOrganization) o;
        this.enterprise = e;
        this.patient = (Patient) ua.getEmployee();
        this.ecoSystem = es;
        lblDonorName.setText(userAccount.getEmployee().getName() + "!!");
        //populateVStable();
        //populateWorkReqTable();
        populateAppointments();
    }

    public void populateAppointments() {
        DefaultTableModel model = (DefaultTableModel) appointMentRequestJTable1.getModel();

        model.setRowCount(0);
        for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) {
            if (request instanceof AppointmentWorkRequest) {
                Object[] row = new Object[5];
                row[0] = request;
                row[1] = request.getReceiver() == null ? null : request.getReceiver().getEmployee().getName();
                row[2] = ((AppointmentWorkRequest) request).getAppointmentDateTime() == null ? null
                        : ((AppointmentWorkRequest) request).getAppointmentDateTime();
                row[3] = request.getStatus();
                String result = ((AppointmentWorkRequest) request).getTestResult();
                row[4] = result == null ? "Waiting" : result;

                model.addRow(row);
            }
        }

    }

    /**
     * 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() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        lblDonorName = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        appointMentRequestJTable1 = new javax.swing.JTable();
        backJButton = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(242, 246, 246));

        jLabel1.setFont(new java.awt.Font("Calibri", 2, 16)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 135, 81));
        jLabel1.setText("Welcome");

        jLabel2.setFont(new java.awt.Font("Calibri", 2, 16)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(0, 135, 81));
        jLabel2.setText("How are you doing today?");

        lblDonorName.setFont(new java.awt.Font("Calibri", 2, 16)); // NOI18N
        lblDonorName.setForeground(new java.awt.Color(0, 135, 81));
        lblDonorName.setText("jLabel1");

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
                javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "My Appointment List",
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 1, 14))); // NOI18N

        appointMentRequestJTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][] { { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null } },
                new String[] { "Message", "Doctor", "DateAndTime", "Status", "Result" }) {
            Class[] types = new Class[] { java.lang.Object.class, java.lang.String.class, java.lang.String.class,
                    java.lang.String.class, java.lang.String.class };
            boolean[] canEdit = new boolean[] { false, false, false, false, false };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jScrollPane3.setViewportView(appointMentRequestJTable1);
        if (appointMentRequestJTable1.getColumnModel().getColumnCount() > 0) {
            appointMentRequestJTable1.getColumnModel().getColumn(4).setPreferredWidth(280);
        }

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout
                .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel3Layout.createSequentialGroup()
                                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 1073,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE)));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE));

        backJButton.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        backJButton.setIcon(
                new javax.swing.ImageIcon(getClass().getResource("/userinterface/PatientRole/backButton.png"))); // NOI18N
        backJButton.setText("Back");
        backJButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJButtonActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Cambria", 1, 24)); // NOI18N
        jLabel8.setText("Patient's Past Appointment And Visit Details ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel8))
                        .addGroup(layout.createSequentialGroup().addGap(18, 18, 18).addComponent(backJButton))
                        .addGroup(layout.createSequentialGroup().addGap(256, 256, 256).addComponent(jLabel1)
                                .addGap(2, 2, 2).addComponent(lblDonorName)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel2))
                        .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jPanel3,
                                javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(32, Short.MAX_VALUE)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout.createSequentialGroup().addGap(21, 21, 21).addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblDonorName).addComponent(jLabel1).addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(92, 92, 92).addComponent(backJButton).addContainerGap(162, Short.MAX_VALUE)));
    }// </editor-fold>//GEN-END:initComponents

    private void backJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJButtonActionPerformed
        userProcessContainer.remove(this);
        /*Component[] componentArray = userProcessContainer.getComponents();
        Component component = componentArray[componentArray.length - 1];
        PatientWorkAreaJPanel pwajp = (PatientWorkAreaJPanel) component;
        pwajp.populateVStable();
        pwajp.populateWorkReqTable();
        pwajp.populateAppointments();*/
        CardLayout layout = (CardLayout) userProcessContainer.getLayout();
        layout.previous(userProcessContainer);
    }//GEN-LAST:event_backJButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable appointMentRequestJTable1;
    private javax.swing.JButton backJButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JLabel lblDonorName;
    // End of variables declaration//GEN-END:variables
}