userinterface.DoctorWorkArea.DiagnosePatientJPanel.java Source code

Java tutorial

Introduction

Here is the source code for userinterface.DoctorWorkArea.DiagnosePatientJPanel.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.DoctorWorkArea;

import Business.Employee.Employee;
import Business.Enterprise.Enterprise;
import Business.OrderCatalog.Order;
import Business.OrderCatalog.OrderItem;
import Business.Organization.DietitianOrganization;
import Business.Organization.DoctorOrganization;
import Business.Organization.LabTechnicianOrganization;
import Business.Organization.Organization;
import Business.Organization.PatientOrganization;
import Business.ProductCatalog.Product;
import Business.TreatmentCatalog.TreatedFor;
import Business.UserAccount.UserAccount;
import Business.VitalSign.VitalSign;
import Business.WorkQueue.DietitianWorkRequest;
import Business.WorkQueue.LabTechnicianWorkRequest;
import Business.WorkQueue.WorkRequest;
import com.skype.Call;
import com.skype.NotAttachedException;
import com.skype.Skype;
import com.skype.SkypeException;
import java.awt.CardLayout;
import java.awt.Color;
import java.time.Clock;
import java.util.HashMap;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
import java.util.Properties;
import java.util.UUID;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRTableModelDataSource;
import net.sf.jasperreports.view.JasperViewer;
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.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

/**
 *
 * @author Neelu
 */
public class DiagnosePatientJPanel extends javax.swing.JPanel {

    private JPanel userProcessContainer;
    private UserAccount userAccount;
    private DoctorOrganization doctorOrganization;
    private Enterprise enterprise;
    private static final int SUBTRACT = -1;
    private DefaultTableModel tableModel;

    /**
     * Creates new form DiagnosePatientJPanel
     */
    public DiagnosePatientJPanel(JPanel upc, DoctorOrganization d, UserAccount ua, Enterprise e) {
        initComponents();
        userProcessContainer = upc;
        userAccount = ua;
        doctorOrganization = d;
        enterprise = e;

        populatePatientCombo();
        populateLabRequestTable();
        populateDietRequestTable();

    }

    public void populatePatientCombo() {
        Organization org = null;
        for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
            if (organization instanceof PatientOrganization) {
                org = organization;
                break;
            }
        }
        if (org != null) {
            for (Employee emp : org.getEmployeeDirectory().getEmployeeList()) {
                patientCombo.addItem(emp);
                patientCombo1.addItem(emp);
                patientCombo2.addItem(emp);
                patientCombo4.addItem(emp);
                patientCombo5.addItem(emp);
                patientCombo6.addItem(emp);
            }
        }

    }

    public void populateVitalSignTable() {

        DefaultTableModel dtm = (DefaultTableModel) vitalSignTable.getModel();

        int rowcount = vitalSignTable.getRowCount();

        for (int i = rowcount - 1; i >= 0; i--) {
            dtm.removeRow(i);
        }
        Employee patient = (Employee) patientCombo.getSelectedItem();

        for (VitalSign vs : patient.getMedicalRecord().getVitalSignHistory().getVitalSignList()) {
            Object row[] = new Object[2];
            row[0] = vs;
            row[1] = vs.getStatusReport();
            dtm.addRow(row);
        }

    }

    public boolean isValidEmailAddress(String email) {
        String ePattern = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";
        java.util.regex.Pattern p = java.util.regex.Pattern.compile(ePattern);
        java.util.regex.Matcher m = p.matcher(email);
        return m.matches();
    }

    /**
     * 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();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel8 = new javax.swing.JPanel();
        jButton6 = new javax.swing.JButton();
        backJButton1 = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        skypeTxt = new javax.swing.JTextArea();
        jLabel22 = new javax.swing.JLabel();
        skypeId = new javax.swing.JTextField();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        patientCombo6 = new javax.swing.JComboBox();
        jPanel7 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        labTestRequestJTable = new javax.swing.JTable();
        jLabel9 = new javax.swing.JLabel();
        patientCombo2 = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        dateChooser = new com.toedter.calendar.JDateChooser();
        refreshJButton = new javax.swing.JButton();
        backJButton2 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        patientCombo = new javax.swing.JComboBox();
        jScrollPane3 = new javax.swing.JScrollPane();
        vitalSignTable = new javax.swing.JTable();
        jLabel12 = new javax.swing.JLabel();
        patientNameTextField = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        respiratoryTextField = new javax.swing.JTextField();
        heartRateTextField = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        patientIdTextField = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        ageTextField = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        bloodPressureTextField = new javax.swing.JTextField();
        weightTextField = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        doctorTextField = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        timestampTextField = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        backJButton = new javax.swing.JButton();
        barBtn = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        patientCombo1 = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        productTable = new javax.swing.JTable();
        jLabel8 = new javax.swing.JLabel();
        addtoCartButton6 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        quantitySpinner = new javax.swing.JSpinner();
        backJButton3 = new javax.swing.JButton();
        jLabel33 = new javax.swing.JLabel();
        emailTxt = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLabel20 = new javax.swing.JLabel();
        patientCombo4 = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        dateChooser1 = new com.toedter.calendar.JDateChooser();
        jButton3 = new javax.swing.JButton();
        jLabel24 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        dietRequestJTable = new javax.swing.JTable();
        refreshJButton1 = new javax.swing.JButton();
        jLabel25 = new javax.swing.JLabel();
        backJButton4 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel26 = new javax.swing.JLabel();
        patientCombo5 = new javax.swing.JComboBox();
        jButton4 = new javax.swing.JButton();
        treatedCombo = new javax.swing.JComboBox();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        resumeCombo = new javax.swing.JComboBox();
        jLabel30 = new javax.swing.JLabel();
        operationCombo = new javax.swing.JComboBox();
        jButton7 = new javax.swing.JButton();
        backJButton5 = new javax.swing.JButton();
        jLabel34 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 36)); // NOI18N
        jLabel1.setText("Diagnose Patient");

        jTabbedPane2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED,
                java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white));
        jTabbedPane2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

        jPanel8.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED,
                java.awt.Color.gray, java.awt.Color.gray, java.awt.Color.gray, java.awt.Color.gray));
        jPanel8.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jButton6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jButton6.setText("Send Skype Message");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jPanel8.add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 380, 279, 92));

        backJButton1.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
        backJButton1.setText("<< Back");
        backJButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJButton1ActionPerformed(evt);
            }
        });
        jPanel8.add(backJButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 570, -1, -1));

        skypeTxt.setColumns(20);
        skypeTxt.setRows(5);
        jScrollPane5.setViewportView(skypeTxt);

        jPanel8.add(jScrollPane5, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 260, 280, -1));

        jLabel22.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel22.setText("Enter Skype ID");
        jPanel8.add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 160, -1, -1));

        skypeId.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        skypeId.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                skypeIdActionPerformed(evt);
            }
        });
        jPanel8.add(skypeId, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 160, 160, -1));

        jLabel31.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel31.setText("Enter Message");
        jPanel8.add(jLabel31, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 220, -1, -1));

        jLabel32.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel32.setText("Select Patient");
        jPanel8.add(jLabel32, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 100, -1, 30));

        patientCombo6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        patientCombo6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                patientCombo6ActionPerformed(evt);
            }
        });
        jPanel8.add(patientCombo6, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 100, 160, -1));

        jTabbedPane2.addTab("Skype Diagnosis", jPanel8);

        jPanel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED,
                java.awt.Color.black, java.awt.Color.black, java.awt.Color.black, java.awt.Color.black));
        jPanel7.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel7.setText("Check Lab Technician's Request");
        jPanel7.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 360, -1, -1));

        labTestRequestJTable.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        labTestRequestJTable.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[] { "Sender", "Patient Name", "Receiver", "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[] { true, false, false, false, false };

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

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jScrollPane2.setViewportView(labTestRequestJTable);

        jPanel7.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 400, 730, 160));

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel9.setText("Select Patient");
        jPanel7.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 160, -1, -1));

        patientCombo2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        patientCombo2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                patientCombo2MouseClicked(evt);
            }
        });
        patientCombo2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                patientCombo2ActionPerformed(evt);
            }
        });
        jPanel7.add(patientCombo2, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 160, 140, -1));

        jLabel10.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel10.setText("Request Lab Tests");
        jPanel7.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(411, 36, -1, -1));

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jButton1.setText("Order Test");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel7.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(229, 287, 137, -1));

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel11.setText("Request Date");
        jPanel7.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(132, 227, -1, -1));

        dateChooser.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel7.add(dateChooser, new org.netbeans.lib.awtextra.AbsoluteConstraints(312, 221, 140, -1));

        refreshJButton.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        refreshJButton.setText("Refresh");
        refreshJButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshJButtonActionPerformed(evt);
            }
        });
        jPanel7.add(refreshJButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(780, 360, -1, -1));

        backJButton2.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
        backJButton2.setText("<< Back");
        backJButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJButton2ActionPerformed(evt);
            }
        });
        jPanel7.add(backJButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 590, -1, -1));

        jTabbedPane2.addTab("Request Tests", jPanel7);

        jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED,
                java.awt.Color.lightGray, java.awt.Color.lightGray, java.awt.Color.lightGray,
                java.awt.Color.lightGray));
        jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel2.setText("Check Vital Signs");
        jPanel5.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 30, -1, -1));

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel3.setText("Select Patient");
        jPanel5.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 130, -1, -1));

        patientCombo.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        patientCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                patientComboActionPerformed(evt);
            }
        });
        jPanel5.add(patientCombo, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 130, 160, -1));

        vitalSignTable.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        vitalSignTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

        }, new String[] { "TimeStamp", "Vital Sign Status" }));
        jScrollPane3.setViewportView(vitalSignTable);

        jPanel5.add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 170, 730, 170));

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel12.setText("Patient Name");
        jPanel5.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 100, -1, -1));

        patientNameTextField.setEditable(false);
        patientNameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                patientNameTextFieldActionPerformed(evt);
            }
        });
        jPanel5.add(patientNameTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 100, 150, -1));

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel13.setText("Respiratory Rate");
        jPanel5.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 260, -1, -1));

        respiratoryTextField.setEditable(false);
        jPanel5.add(respiratoryTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 260, 150, -1));

        heartRateTextField.setEditable(false);
        jPanel5.add(heartRateTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 300, 150, -1));

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel14.setText("Heart Rate");
        jPanel5.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 300, -1, -1));

        patientIdTextField.setEditable(false);
        jPanel5.add(patientIdTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 140, 150, -1));

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel15.setText("Patient ID");
        jPanel5.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 140, -1, -1));

        jLabel16.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel16.setText("Age");
        jPanel5.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 180, -1, -1));

        ageTextField.setEditable(false);
        ageTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ageTextFieldActionPerformed(evt);
            }
        });
        jPanel5.add(ageTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 180, 150, -1));

        jLabel17.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel17.setText("Blood Pressure");
        jPanel5.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 340, -1, -1));

        bloodPressureTextField.setEditable(false);
        jPanel5.add(bloodPressureTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 340, 150, -1));

        weightTextField.setEditable(false);
        jPanel5.add(weightTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 380, 150, -1));

        jLabel18.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel18.setText("Weight");
        jPanel5.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 380, -1, -1));

        doctorTextField.setEditable(false);
        doctorTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                doctorTextFieldActionPerformed(evt);
            }
        });
        jPanel5.add(doctorTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 220, 150, -1));

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel19.setText("Primary Doctor");
        jPanel5.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 220, -1, -1));

        jLabel21.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel21.setText("Timestamp");
        jPanel5.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 420, -1, -1));

        timestampTextField.setEditable(false);
        timestampTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                timestampTextFieldActionPerformed(evt);
            }
        });
        jPanel5.add(timestampTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 420, 150, -1));

        jButton2.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
        jButton2.setText("View Records");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(980, 120, 150, -1));

        backJButton.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
        backJButton.setText("<< Back");
        backJButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJButtonActionPerformed(evt);
            }
        });
        jPanel5.add(backJButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 570, -1, -1));

        barBtn.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        barBtn.setText("Bar Chart");
        barBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                barBtnActionPerformed(evt);
            }
        });
        jPanel5.add(barBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 410, 120, -1));

        jTabbedPane2.addTab("Check Vital Signs", jPanel5);

        jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED,
                java.awt.Color.darkGray, java.awt.Color.darkGray, java.awt.Color.darkGray,
                java.awt.Color.darkGray));
        jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel4.setText("Prescribe Medicines");
        jPanel6.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 55, -1, -1));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel5.setText("Select Patient");
        jPanel6.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(216, 149, -1, -1));

        patientCombo1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        patientCombo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                patientCombo1ActionPerformed(evt);
            }
        });
        jPanel6.add(patientCombo1, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 140, 200, -1));

        productTable.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        productTable
                .setModel(new javax.swing.table.DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null } },
                        new String[] { "Name", "Product Id", "Price", "Avail" }) {
                    boolean[] canEdit = new boolean[] { false, false, false, false };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit[columnIndex];
                    }
                });
        jScrollPane1.setViewportView(productTable);

        jPanel6.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 280, 590, 100));

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel8.setText("Supplier Product Catalog");
        jPanel6.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 250, 240, -1));

        addtoCartButton6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        addtoCartButton6.setText("Send Mail");
        addtoCartButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addtoCartButton6ActionPerformed(evt);
            }
        });
        jPanel6.add(addtoCartButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 490, 150, -1));

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel6.setText("Quantity:");
        jPanel6.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 390, 80, 30));

        quantitySpinner.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null,
                Integer.valueOf(1)));
        jPanel6.add(quantitySpinner, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 390, 100, -1));

        backJButton3.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
        backJButton3.setText("<< Back");
        backJButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJButton3ActionPerformed(evt);
            }
        });
        jPanel6.add(backJButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 600, -1, -1));

        jLabel33.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel33.setText("Email- ID");
        jPanel6.add(jLabel33, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 200, -1, -1));

        emailTxt.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel6.add(emailTxt, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 190, 200, -1));

        jTabbedPane2.addTab("Prescribe Medicines", jPanel6);

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel20.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel20.setText("Select Patient");
        jPanel1.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 160, -1, -1));

        patientCombo4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        patientCombo4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                patientCombo4MouseClicked(evt);
            }
        });
        patientCombo4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                patientCombo4ActionPerformed(evt);
            }
        });
        jPanel1.add(patientCombo4, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 160, 140, -1));

        jLabel23.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel23.setText("Request Date");
        jPanel1.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 210, -1, -1));

        dateChooser1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jPanel1.add(dateChooser1, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 210, 140, -1));

        jButton3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jButton3.setText("Order");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 290, 137, -1));

        jLabel24.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel24.setText("Check Dietitian Request Status");
        jPanel1.add(jLabel24, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 360, -1, -1));

        dietRequestJTable.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        dietRequestJTable.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[] { "Sender", "Patient Name", "Receiver", "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[] { true, false, false, false, false };

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

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jScrollPane4.setViewportView(dietRequestJTable);

        jPanel1.add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 400, 700, 97));

        refreshJButton1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        refreshJButton1.setText("Refresh");
        refreshJButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshJButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(refreshJButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(900, 360, -1, -1));

        jLabel25.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel25.setText("Request Diet Plan from Dietitian");
        jPanel1.add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 20, -1, -1));

        backJButton4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        backJButton4.setText("<< Back");
        backJButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJButton4ActionPerformed(evt);
            }
        });
        jPanel1.add(backJButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 570, -1, -1));

        jTabbedPane2.addTab("Request DietPlan", jPanel1);

        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel26.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel26.setText("Select Patient");
        jPanel2.add(jLabel26, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 100, -1, -1));

        patientCombo5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        patientCombo5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                patientCombo5MouseClicked(evt);
            }
        });
        patientCombo5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                patientCombo5ActionPerformed(evt);
            }
        });
        jPanel2.add(patientCombo5, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 100, 130, -1));

        jButton4.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
        jButton4.setText("Generate Medical Report");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 440, 240, -1));

        treatedCombo.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        treatedCombo.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Cancer", "Post Operative Complication",
                        "Wound Healing", "Multiple Trauma", "Trauma with Steroids", "Burns", "Bone Fracture" }));
        jPanel2.add(treatedCombo, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 310, 100, 20));

        jLabel27.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel27.setText("Resume Work");
        jPanel2.add(jLabel27, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 230, -1, -1));

        jLabel28.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel28.setText("Update Medical Record");
        jPanel2.add(jLabel28, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 190, -1, -1));

        jLabel29.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel29.setText("Operation Performed");
        jPanel2.add(jLabel29, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 270, -1, -1));

        resumeCombo.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        resumeCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Yes", "No" }));
        jPanel2.add(resumeCombo, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 230, 100, 20));

        jLabel30.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel30.setText("Treated For");
        jPanel2.add(jLabel30, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 310, -1, -1));

        operationCombo.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        operationCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Yes", "No" }));
        jPanel2.add(operationCombo, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 270, 100, 20));

        jButton7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jButton7.setText("Update");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton7, new org.netbeans.lib.awtextra.AbsoluteConstraints(730, 260, 130, -1));

        backJButton5.setFont(new java.awt.Font("Tahoma", 1, 16)); // NOI18N
        backJButton5.setText("<< Back");
        backJButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJButton5ActionPerformed(evt);
            }
        });
        jPanel2.add(backJButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 590, -1, -1));

        jLabel34.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel34.setText("Medical Report");
        jPanel2.add(jLabel34, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 20, -1, -1));

        jTabbedPane2.addTab("Generate Medical Report", jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jTabbedPane2)
                        .addGroup(layout.createSequentialGroup().addGap(413, 413, 413).addComponent(jLabel1)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addGap(9, 9, 9).addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTabbedPane2)));
    }// </editor-fold>//GEN-END:initComponents

    private void addtoCartButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addtoCartButton6ActionPerformed
        // TODO add your handling code here:

        int selectedRow = productTable.getSelectedRow();
        if (selectedRow < 0) {
            JOptionPane.showMessageDialog(null, "Please select a Product from the Table");
            return;
        }

        Product product = (Product) productTable.getValueAt(selectedRow, 0);
        int quantity = (Integer) quantitySpinner.getValue();
        if (quantity == 0) {
            JOptionPane.showMessageDialog(null, "Please enter a number for Medicine Quantity!");
            return;
        }

        if (product != null) {
            updateQuantity(product, quantity, SUBTRACT);
        }
        String medName = product.getProdName();

        Employee patient = (Employee) patientCombo1.getSelectedItem();
        patient.getMedicalRecord().setMedicinePrescribed(medName);
        String email = patient.getEmail();

        if (email.trim().isEmpty()) {
            JOptionPane.showMessageDialog(null, "Patient profile is not updated for email!");
            return;
        }

        if (isValidEmailAddress(email)) {
            String uuid = UUID.randomUUID().toString();
            //JOptionPane.showMessageDialog(null, "Barcode Generated and attached to the sample");

            Properties props = new Properties();
            props.put("mail.smtp.host", "smtp.gmail.com");
            props.put("mail.smtp.socketFactory.port", "465");
            props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
            props.put("mail.smtp.auth", "true");
            props.put("mail.smtp.port", "465");

            Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication("neelzsaxena@gmail.com", "painforever24");
                }

            }

            );
            try {
                Message message = new MimeMessage(session);
                message.setFrom(new InternetAddress("neelzsaxena@gmail.com"));
                message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(email));
                message.setSubject("Prescribed Medicines");
                message.setText("The medicine Prescribed is :" + medName + '\n' + "The Quantity authorized is:"
                        + quantity + '\n' + "The unique barcode is:" + uuid);
                Transport.send(message);
                populateTable();
                JOptionPane.showMessageDialog(null, "message sent");
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "message failed");
            }

        } else {
            JOptionPane.showMessageDialog(null, "Invalid Email Id");
            return;
        }

        //        String uuid = UUID.randomUUID().toString();
        //        //JOptionPane.showMessageDialog(null, "Barcode Generated and attached to the sample");
        //        
        //        Properties props = new Properties();
        //        props.put("mail.smtp.host", "smtp.gmail.com");
        //        props.put("mail.smtp.socketFactory.port", "465");
        //        props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        //        props.put("mail.smtp.auth", "true");
        //        props.put("mail.smtp.port", "465");
        //
        //            Session  session = Session.getDefaultInstance(props,
        //                    new javax.mail.Authenticator(){
        //                        protected PasswordAuthentication getPasswordAuthentication(){
        //      return new PasswordAuthentication("neelzsaxena@gmail.com", "painforever24");
        //                    }
        //   
        //            }
        //
        //   );
        //        try{
        //            Message message = new MimeMessage(session);
        //            message.setFrom(new InternetAddress("neelzsaxena@gmail.com"));
        //            message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(email));
        //            message.setSubject("Prescribed Medicines");
        //            message.setText("The medicine Prescribed is :" +medName + '\n'+
        //                            "The Quantity authorized is:"+quantity + '\n'+
        //                            "The unique barcode is:"+uuid);
        //                Transport.send(message);
        //                    populateTable();
        //                    JOptionPane.showMessageDialog(null,"message sent");
        //            }catch(Exception e){
        //                JOptionPane.showMessageDialog(null,"message failed");
        //            }

    }//GEN-LAST:event_addtoCartButton6ActionPerformed

    private void patientCombo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patientCombo1ActionPerformed
        // TODO add your handling code here:
        Employee patient = (Employee) patientCombo1.getSelectedItem();
        emailTxt.setText(patient.getEmail());
        populateTable();
    }//GEN-LAST:event_patientCombo1ActionPerformed

    private void patientCombo2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patientCombo2ActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_patientCombo2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:

        Employee patient = (Employee) patientCombo2.getSelectedItem();

        LabTechnicianWorkRequest request = new LabTechnicianWorkRequest();
        String patName = patient.getName();
        if (patName.trim().isEmpty() || dateChooser.getDate() == null) {
            JOptionPane.showMessageDialog(null, "Please enter all the fields required!");
            return;
        }

        request.setMessage(patName);
        request.setSender(userAccount);
        request.setStatus("Sent");

        request.setRequestDate(dateChooser.getDate());
        request.setPatientName(patient.getName()); //To identify the patient(to enter into his medical record) once the lab assistant picks the request.
        patient.setPrimaryDoctor(userAccount.getEmployee().getName());
        patient.getMedicalRecord().setAdmissionDate(dateChooser.getDate());
        patient.getMedicalRecord().setDiagnosisBasedUpon("Skype");
        patient.getMedicalRecord().setDoctorName(userAccount.getEmployee().getName());

        Organization org = null;
        for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
            if (organization instanceof LabTechnicianOrganization) {
                org = organization;
                break;
            }
        }
        if (org != null) {
            org.getWorkQueue().getWorkRequestList().add(request);
            userAccount.getWorkQueue().getWorkRequestList().add(request);
        }

        populateLabRequestTable();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void patientCombo2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_patientCombo2MouseClicked
        // TODO add your handling code here:

    }//GEN-LAST:event_patientCombo2MouseClicked

    private void patientNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patientNameTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_patientNameTextFieldActionPerformed

    private void ageTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ageTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ageTextFieldActionPerformed

    private void doctorTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doctorTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_doctorTextFieldActionPerformed

    private void patientComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patientComboActionPerformed
        // TODO add your handling code here:
        //calculateStatus();
        populateVitalSignTable();

    }//GEN-LAST:event_patientComboActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        Employee patient = (Employee) patientCombo.getSelectedItem();
        int selectedRow = vitalSignTable.getSelectedRow();
        if (selectedRow >= 0) {
            VitalSign vs = (VitalSign) vitalSignTable.getValueAt(selectedRow, 0);
            respiratoryTextField.setText(String.valueOf(vs.getRespiratoryRate()));
            heartRateTextField.setText(String.valueOf(vs.getHeartRate()));
            bloodPressureTextField.setText(String.valueOf(vs.getBloodPressure()));
            weightTextField.setText(String.valueOf(vs.getWeight()));
            timestampTextField.setText(vs.getTimestamp());

            patientNameTextField.setText(patient.getName());
            patientIdTextField.setText(Integer.toString(patient.getId()));
            ageTextField.setText(Integer.toString(patient.getAge()));
            doctorTextField.setText(patient.getPrimaryDoctor());

        } else {
            JOptionPane.showMessageDialog(null, "Please select a row from the first table", "Warning",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void backJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJButtonActionPerformed

        userProcessContainer.remove(this);
        CardLayout layout = (CardLayout) userProcessContainer.getLayout();
        layout.previous(userProcessContainer);
    }//GEN-LAST:event_backJButtonActionPerformed

    private void refreshJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshJButtonActionPerformed
        populateLabRequestTable();
    }//GEN-LAST:event_refreshJButtonActionPerformed

    private void patientCombo4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_patientCombo4MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_patientCombo4MouseClicked

    private void patientCombo4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patientCombo4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_patientCombo4ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        Employee patient = (Employee) patientCombo4.getSelectedItem();
        if (patient == null || dateChooser1.getDate() == null) {
            JOptionPane.showMessageDialog(null, "Please enter all the fields required!");
            return;
        }

        DietitianWorkRequest request = new DietitianWorkRequest();
        String patName = patient.getName();
        request.setMessage(patName);
        request.setSender(userAccount);
        request.setStatus("Sent");

        request.setRequestDate(dateChooser1.getDate());

        Organization org = null;
        for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
            if (organization instanceof DietitianOrganization) {
                org = organization;
                break;
            }
        }
        if (org != null) {
            org.getWorkQueue().getWorkRequestList().add(request);
            userAccount.getWorkQueue().getWorkRequestList().add(request);
        }

        populateDietRequestTable();

    }//GEN-LAST:event_jButton3ActionPerformed

    public void populateDietRequestTable() {
        DefaultTableModel model = (DefaultTableModel) dietRequestJTable.getModel();
        model.setRowCount(0);

        DietitianWorkRequest req = null;
        for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) {
            if (request instanceof DietitianWorkRequest) {

                Object[] row = new Object[5];
                row[0] = request;
                row[1] = request.getMessage();
                row[2] = request.getReceiver();
                row[3] = request.getStatus();
                String result = ((DietitianWorkRequest) request).getResult();
                row[4] = result == null ? "Waiting" : result;

                model.addRow(row);
            }
        }

    }

    private void refreshJButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshJButton1ActionPerformed
        // TODO add your handling code here:
        populateDietRequestTable();
    }//GEN-LAST:event_refreshJButton1ActionPerformed

    private void patientCombo5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_patientCombo5MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_patientCombo5MouseClicked

    private void patientCombo5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patientCombo5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_patientCombo5ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        Employee patient = (Employee) patientCombo5.getSelectedItem();

        String[] columnNames = { "Patient Name", "Patient ID", "Doctor Name", "Age", "Allergies", "Special Needs",
                "Calorie Intake", "Protien Intake", "Amino Acid" };
        String[][] data = {
                { patient.getName(), Integer.toString(patient.getId()), patient.getMedicalRecord().getDoctorName(),
                        Integer.toString(patient.getAge()), patient.getMedicalRecord().getAllergies(),
                        patient.getMedicalRecord().getSpecialNeeds(), patient.getMedicalRecord().getCalorieIntake(),
                        patient.getMedicalRecord().getProtienIntake(), patient.getMedicalRecord().getAminoAcid() },

        };
        tableModel = new DefaultTableModel(data, columnNames);
        SimpleReport();

    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        try {

            String message = skypeTxt.getText();

            Skype.chat(skypeId.getText()).send(message);

            System.out.println("Message sent!");
            JOptionPane.showMessageDialog(null, "Message sent! Check Skype.");
        } catch (SkypeException e) {
            JOptionPane.showMessageDialog(null, "Skype not logged in");
            //e.printStackTrace();
        }

    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        Employee patient = (Employee) patientCombo5.getSelectedItem();
        String operation = (String) operationCombo.getSelectedItem();
        patient.getMedicalRecord().setIsOperationPerformed(operation);

        String resumeWork = (String) resumeCombo.getSelectedItem();
        patient.getMedicalRecord().setResumeWork(resumeWork);

        String treatedFor = (String) treatedCombo.getSelectedItem();
        patient.getMedicalRecord().setTreatedFor(treatedFor);

        TreatedFor t = enterprise.getTreatmentCatalog().searchTreatment(treatedFor);
        if (t != null) {
            t.setCount(t.getCount() + 1);
        } else {
            TreatedFor treat = enterprise.getTreatmentCatalog().addtreatedFor();
            treat.setTreatment(treatedFor);
            treat.setCount(treat.getCount() + 1);
        }

        JOptionPane.showMessageDialog(null, "Patient Record Updated");
    }//GEN-LAST:event_jButton7ActionPerformed

    private void timestampTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timestampTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_timestampTextFieldActionPerformed

    private void barBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_barBtnActionPerformed
        // TODO add your handling code here:
        DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
        int i = 1;
        Employee patient = (Employee) patientCombo.getSelectedItem();

        for (VitalSign vs : patient.getMedicalRecord().getVitalSignHistory().getVitalSignList()) {

            dataSet.setValue(vs.getBloodPressure(), "Blood Pressure", vs.getTimestamp());

            i++;

        }

        JFreeChart chart = ChartFactory.createBarChart("Blood Pressure Graph", "Timestamp", "Blood Pressure",
                dataSet, PlotOrientation.VERTICAL, false, true, false);
        CategoryPlot p = chart.getCategoryPlot();
        p.setRangeGridlinePaint(Color.BLACK);
        ChartFrame frame = new ChartFrame("Bar Chart for Patient", chart);
        frame.setVisible(true);
        frame.setSize(800, 550);

    }//GEN-LAST:event_barBtnActionPerformed

    private void backJButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_backJButton1ActionPerformed

    private void backJButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_backJButton2ActionPerformed

    private void backJButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_backJButton3ActionPerformed

    private void backJButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJButton4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_backJButton4ActionPerformed

    private void backJButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJButton5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_backJButton5ActionPerformed

    private void skypeIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skypeIdActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_skypeIdActionPerformed

    private void patientCombo6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patientCombo6ActionPerformed
        // TODO add your handling code here:
        Employee patient = (Employee) patientCombo6.getSelectedItem();
        skypeId.setText(patient.getSkypeId());
    }//GEN-LAST:event_patientCombo6ActionPerformed

    public void SimpleReport() {
        JasperPrint jasperPrint = null;

        try {
            JasperCompileManager
                    .compileReportToFile(System.getProperty("user.dir") + "\\Reports3\\newReport.jrxml");
            jasperPrint = JasperFillManager.fillReport(
                    System.getProperty("user.dir") + "\\Reports3\\AircraftReportColumnIndex.jasper", new HashMap(),
                    new JRTableModelDataSource(tableModel));
            JasperViewer jasperViewer = new JasperViewer(jasperPrint);
            jasperViewer.setVisible(true);
        } catch (JRException ex) {
            ex.printStackTrace();
        }

    }

    //     public void calculateStatus(){
    //        Employee patient = (Employee)patientCombo.getSelectedItem();
    //        
    //        for(VitalSign vs: patient.getMedicalRecord().getVitalSignHistory().getVitalSignList() ){
    //            
    //            int resp = vs.getRespiratoryRate();
    //            int heart =vs.getHeartRate();
    //            int bp =vs.getBloodPressure();
    //            int w =vs.getWeight();
    //            
    //            if((patient.getAge()>=1 && patient.getAge()<=3)&&(resp>=20 && resp<=30) && (heart>=80 && heart<=130) && (bp>=80 && bp<=110) && (w>=22 && w<=31)){
    //            vs.setStatusReport("Normal");
    //        }
    //        else if((patient.getAge()>=4 && patient.getAge()<=5)&&(resp>=20 && resp<=30) && (heart>=80 && heart<=120) && (bp>=80 && bp<=110) && (w>=31 && w<=40)){
    //            vs.setStatusReport("Normal");
    //        } 
    //        else if((patient.getAge()>=6 && patient.getAge()<=12)&&(resp>=20 && resp<=30) && (heart>=70 && heart<=110) && (bp>=80 && bp<=120) && (w>=41 && w<=92)){
    //            vs.setStatusReport("Normal");
    //        } 
    //           else if((patient.getAge()>13)&&(resp>=12 && resp<=20) && (heart>=55 && heart<=105) && (bp>=110 && bp<=120) && (w>110)){
    //            vs.setStatusReport("Normal");
    //        } 
    //           else{
    //               vs.setStatusReport("Abnormal");
    //           }
    //            
    //        }
    //       
    //        
    //    }
    public void populateLabRequestTable() {
        DefaultTableModel model = (DefaultTableModel) labTestRequestJTable.getModel();
        model.setRowCount(0);

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

                model.addRow(row);

            }
        }
    }

    public void populateTable() {

        DefaultTableModel model = (DefaultTableModel) productTable.getModel();

        model.setRowCount(0);
        for (Product product : enterprise.getProductCatalog().getProductcatalog()) {

            Object[] row = new Object[4];
            row[0] = product;
            row[1] = product.getModelNumber();
            row[2] = product.getPrice();
            row[3] = product.getAvailableAmount();

            model.addRow(row);

        }
    }

    private void updateQuantity(Product product, int quantity, int flag) {
        if (flag == SUBTRACT) {
            int newAmount = product.getAvailableAmount() - quantity;
            product.setAvailableAmount(newAmount);
        }

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addtoCartButton6;
    private javax.swing.JTextField ageTextField;
    private javax.swing.JButton backJButton;
    private javax.swing.JButton backJButton1;
    private javax.swing.JButton backJButton2;
    private javax.swing.JButton backJButton3;
    private javax.swing.JButton backJButton4;
    private javax.swing.JButton backJButton5;
    private javax.swing.JButton barBtn;
    private javax.swing.JTextField bloodPressureTextField;
    private com.toedter.calendar.JDateChooser dateChooser;
    private com.toedter.calendar.JDateChooser dateChooser1;
    private javax.swing.JTable dietRequestJTable;
    private javax.swing.JTextField doctorTextField;
    private javax.swing.JTextField emailTxt;
    private javax.swing.JTextField heartRateTextField;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTable labTestRequestJTable;
    private javax.swing.JComboBox operationCombo;
    private javax.swing.JComboBox patientCombo;
    private javax.swing.JComboBox patientCombo1;
    private javax.swing.JComboBox patientCombo2;
    private javax.swing.JComboBox patientCombo4;
    private javax.swing.JComboBox patientCombo5;
    private javax.swing.JComboBox patientCombo6;
    private javax.swing.JTextField patientIdTextField;
    private javax.swing.JTextField patientNameTextField;
    private javax.swing.JTable productTable;
    private javax.swing.JSpinner quantitySpinner;
    private javax.swing.JButton refreshJButton;
    private javax.swing.JButton refreshJButton1;
    private javax.swing.JTextField respiratoryTextField;
    private javax.swing.JComboBox resumeCombo;
    private javax.swing.JTextField skypeId;
    private javax.swing.JTextArea skypeTxt;
    private javax.swing.JTextField timestampTextField;
    private javax.swing.JComboBox treatedCombo;
    private javax.swing.JTable vitalSignTable;
    private javax.swing.JTextField weightTextField;
    // End of variables declaration//GEN-END:variables
}