Subversion Repository Public Repository

Pharmacy_09_03_18

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcarepharmacy.view;

import com.bestray.healthcarecommonutil.util.ButtonType;
import com.bestray.healthcarecommonutil.util.GlossyButton;
import com.bestray.healthcarecommonutil.util.Theme;
import com.bestray.healthcarecommonutil.vo.TPatient;
import com.bestray.healthcarecommonutil.vo.TPatientEncounter;
import com.bestray.healthcarepharmacy.controller.PharmacyPatientController;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.util.Vector;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author User1
 */
public class PatientRecordDialog extends javax.swing.JDialog {
    
    /**
     * Creates new form PatientRecordDialog
     */
    
    public PatientRecordDialog(java.awt.Frame parent, boolean modal, Vector<Vector<String>> patientData) {
        super(parent, modal);
        populate();
        initComponents();
        displaySearch(patientData);
    }
    
    
    /**
     * 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() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        patient_record_table = new javax.swing.JTable(){
            public boolean isCellEditable(int row, int column){
                return false;
            }
            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
                Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
                if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                    c.setForeground(Color.BLACK);
                    c.setBackground(new Color(200, 225, 250));
                }
                else if(rowIndex % 2 == 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else if(rowIndex % 2 != 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else {
                    c.setForeground(Color.BLACK);
                    c.setBackground(getBackground());
                }
                return c;
            }

        };
        jLabel1 = new javax.swing.JLabel();
        cancel_button = new GlossyButton("Cancel",Theme.GLOSSY_GREEN_THEME,ButtonType.BUTTON_ROUNDED_RECTANGLUR);
        select_button = new GlossyButton("Select",Theme.GLOSSY_GREEN_THEME,ButtonType.BUTTON_ROUNDED_RECTANGLUR);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Search Results");

        jPanel1.setBackground(new java.awt.Color(253, 251, 251));
        jPanel1.setPreferredSize(new java.awt.Dimension(1031, 672));

        jScrollPane1.setBackground(new java.awt.Color(253, 251, 251));

        patient_record_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        patient_record_table.setBackground(new java.awt.Color(253, 251, 251));
        patient_record_table.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        patient_record_table.setModel(new javax.swing.table.DefaultTableModel(patientData,patientHeader));
        patient_record_table.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        patient_record_table.setRowHeight(25);
        patient_record_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        /*
        patient_record_table.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        patient_record_table.getColumnModel().getColumn(0).setPreferredWidth(10);
        patient_record_table.getColumnModel().getColumn(0).setMaxWidth(40);

        patient_record_table.getColumnModel().getColumn(1).setPreferredWidth(100);
        patient_record_table.getColumnModel().getColumn(1).setMaxWidth(105);

        patient_record_table.getColumnModel().getColumn(2).setPreferredWidth(190);
        patient_record_table.getColumnModel().getColumn(2).setMaxWidth(190);

        patient_record_table.getColumnModel().getColumn(3).setPreferredWidth(105);
        patient_record_table.getColumnModel().getColumn(3).setMaxWidth(105);

        patient_record_table.getColumnModel().getColumn(4).setPreferredWidth(105);
        patient_record_table.getColumnModel().getColumn(4).setMaxWidth(105);

        patient_record_table.getColumnModel().getColumn(5).setPreferredWidth(105);
        patient_record_table.getColumnModel().getColumn(5).setMaxWidth(105);
        */
        patient_record_table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                patient_record_tableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(patient_record_table);

        jLabel1.setBackground(new java.awt.Color(253, 251, 251));
        jLabel1.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(102, 135, 237));
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search_patient-icon32X32.png"))); // NOI18N

        cancel_button.setBackground(new java.awt.Color(253, 251, 251));
        cancel_button.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        cancel_button.setForeground(new java.awt.Color(68, 62, 173));
        cancel_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cancel24X24.png"))); // NOI18N
        cancel_button.setText("Cancel");
        cancel_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancel_buttonActionPerformed(evt);
            }
        });

        select_button.setBackground(new java.awt.Color(253, 251, 251));
        select_button.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        select_button.setForeground(new java.awt.Color(68, 62, 173));
        select_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/select-icon.png"))); // NOI18N
        select_button.setText("Select");
        select_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                select_buttonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1114, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(select_button)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancel_button))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancel_button, select_button});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(1, 1, 1)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 349, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancel_button)
                    .addComponent(select_button))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {cancel_button, select_button});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 1134, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 438, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel_buttonActionPerformed
         dispose();
    }//GEN-LAST:event_cancel_buttonActionPerformed

    private void patient_record_tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_patient_record_tableMouseClicked
        try{
            if (evt.getClickCount() == 2) {
                int row = patient_record_table.getSelectedRow();
                 patient = pharmacyPatientController.getPatientByPatientId(String.valueOf(patient_record_table.getValueAt(row, 1)));
                 dispose();
            }
           }catch(Exception e){
             e.printStackTrace();
           }
    }//GEN-LAST:event_patient_record_tableMouseClicked

    private void select_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_select_buttonActionPerformed
         try{
                int row = patient_record_table.getSelectedRow();
                 patient = pharmacyPatientController.getPatientByPatientId(String.valueOf(patient_record_table.getValueAt(row, 1)));
                this.dispose();
           }catch(Exception e){
             e.printStackTrace();
           }
    }//GEN-LAST:event_select_buttonActionPerformed

   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancel_button;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable patient_record_table;
    private javax.swing.JButton select_button;
    // End of variables declaration//GEN-END:variables
    private Vector<Vector<String>> patientData = new Vector<Vector<String>>();
    private Vector<String> patientHeader;
    private javax.swing.JFrame MainAPP;
    public static TPatient patient;
    public static TPatientEncounter lastEncounter = null;
    private PharmacyPatientController pharmacyPatientController;
    //private SearchPatientController searchPatientController;
    private int count;
    TableRowSorter<TableModel> sorter;
    
    private void populate(){
        pharmacyPatientController = (PharmacyPatientController)PharmacyHomeFrame.context.getBean("pharmacyPatientController");
        patientHeader = new Vector<String>();
        patientHeader.add("Id");
        patientHeader.add("Patient Id");
        patientHeader.add("Patient Name");
        patientHeader.add("Gender");
        patientHeader.add("Date of Birth");
        patientHeader.add("OP/IP Status");
        patientHeader.add("Home Number");
        patientHeader.add("Mobile Number");
        patientHeader.add("Emergency Number");
        patientHeader.add("Present Address");
        
                
    }
    
    private void displaySearch(Vector<Vector<String>> patientData) {
        patient_record_table.setModel(new javax.swing.table.DefaultTableModel(patientData,patientHeader));
        patient_record_table.getColumnModel().getColumn(0).setPreferredWidth(0);
        patient_record_table.getColumnModel().getColumn(0).setMinWidth(0);
        patient_record_table.getColumnModel().getColumn(0).setMaxWidth(0);
        
        patient_record_table.getColumnModel().getColumn(1).setPreferredWidth(90);
        patient_record_table.getColumnModel().getColumn(1).setMaxWidth(90);

        patient_record_table.getColumnModel().getColumn(2).setPreferredWidth(190);
        patient_record_table.getColumnModel().getColumn(2).setMaxWidth(200);

        patient_record_table.getColumnModel().getColumn(3).setPreferredWidth(80);
        patient_record_table.getColumnModel().getColumn(3).setMaxWidth(80);

        patient_record_table.getColumnModel().getColumn(4).setPreferredWidth(100);
        patient_record_table.getColumnModel().getColumn(4).setMaxWidth(110);

        patient_record_table.getColumnModel().getColumn(5).setPreferredWidth(0);
        patient_record_table.getColumnModel().getColumn(5).setMinWidth(0);
        patient_record_table.getColumnModel().getColumn(5).setMaxWidth(0);
        
        patient_record_table.getColumnModel().getColumn(6).setPreferredWidth(123);
        patient_record_table.getColumnModel().getColumn(6).setMaxWidth(123);
        
        patient_record_table.getColumnModel().getColumn(7).setPreferredWidth(0);
        patient_record_table.getColumnModel().getColumn(7).setMinWidth(0);
        patient_record_table.getColumnModel().getColumn(7).setMaxWidth(0);
        
        patient_record_table.getColumnModel().getColumn(8).setPreferredWidth(123);
        patient_record_table.getColumnModel().getColumn(8).setMaxWidth(123);
        
        sorter = new TableRowSorter<TableModel>();
        sorter = new TableRowSorter<TableModel>(patient_record_table.getModel());
        patient_record_table.setRowSorter(sorter);
        
        count = patient_record_table.getRowCount();
        if(count>1){
            jLabel1.setText(" "+count+" Records found");
        }else{
        jLabel1.setText(" "+count+" Record found");
        }
    }
    
    protected JRootPane createRootPane() {
        JRootPane rootPane = new JRootPane();
        KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
        Action actionListener = new AbstractAction() {
          public void actionPerformed(ActionEvent actionEvent) {
            dispose();
          }
        };
        InputMap inputMap = rootPane
            .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        inputMap.put(stroke, "ESCAPE");
        rootPane.getActionMap().put("ESCAPE", actionListener);

        return rootPane;
    }
}

Commits for Pharmacy_09_03_18/Dr Gyana ProjectSpace/DrGyanaPharmacy/src/main/java/com/bestray/healthcarepharmacy/view/PatientRecordDialog.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 27 Jul, 2018 07:30:57 +0000