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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcareemr.Views;

import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.util.ButtonType;
import com.bestray.healthcarecommonutil.util.DisabledGlassPane;
import com.bestray.healthcarecommonutil.util.GlossyButton;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.Theme;
import com.bestray.healthcarecommonutil.vo.TAppointment;
import com.bestray.healthcarecommonutil.vo.TDepartmentMaster;
import com.bestray.healthcarecommonutil.vo.TDoctorInformation;
import com.bestray.healthcarecommonutil.vo.TPatient;
import com.bestray.healthcareemr.Controller.AppointmentController;
import com.bestray.healthcareemr.Controller.CodeValuesController;
import com.bestray.healthcareemr.Controller.DepartmentMasterController;
import com.bestray.healthcareemr.Controller.DoctorInformationController;
import com.bestray.healthcareemr.Controller.PatientController;
import com.bestray.healthcareemr.Util.CollectionUtil;
import com.bestray.healthcareemr.Util.MessageProperties;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import com.bestray.healthcarecommonutil.vo.TCCodeValues;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import java.util.prefs.Preferences;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellRenderer;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

// TODO: Auto-generated Javadoc
/**
 * The Class AppointmentDialog.
 *
 * @author User1
 */
public class AppointmentDialog extends javax.swing.JDialog {

    /**
     * Creates new form AppointmentDialog.
     *
     * @param parent the parent
     * @param modal the modal
     */
    public AppointmentDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        populateData();
        initComponents();
    }
    
    /**
     * Instantiates a new appointment dialog.
     *
     * @param parent the parent
     * @param modal the modal
     * @param patient the patient
     */
    public AppointmentDialog(java.awt.Frame parent, boolean modal, TPatient patient) {
        super(parent, modal);
        populateData();
        initComponents();
        diplayPatientInfo(patient);
    }
    
    /**
     * Instantiates a new appointment dialog.
     *
     * @param parent the parent
     * @param modal the modal
     * @param appointment the appointment
     */
    public AppointmentDialog(java.awt.Frame parent, boolean modal, TAppointment appointment) {
        super(parent, modal);
        populateData();
        initComponents();
        diplayAppoimentInfo(appointment);
    }

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

        opip_buttonGroup = new javax.swing.ButtonGroup();
        jPanel1 = new SimpleGradientPanel();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        patientName_textbox = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        record_panel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        timeSlot_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;
            }

        };
        vistType_combobox = new javax.swing.JComboBox();
        patientcontact_textbox = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        department_combobox = new javax.swing.JComboBox();
        appointment_jcalendar = new com.toedter.calendar.JCalendar();
        cancel_button = new GlossyButton("Cancel",Theme.GLOSSY_GREEN_THEME,ButtonType.BUTTON_ROUNDED);
        reset_Button = new GlossyButton("Reset",Theme.GLOSSY_GREEN_THEME,ButtonType.BUTTON_ROUNDED);
        search_Button = new GlossyButton("Search",Theme.GLOSSY_GREEN_THEME,ButtonType.BUTTON_ROUNDED);
        doctorName_combo = new javax.swing.JComboBox();
        chooseTime_combo = new javax.swing.JComboBox();
        chooseTime_label = new javax.swing.JLabel();
        ip_radiotb = new javax.swing.JRadioButton();
        op_radiotb = new javax.swing.JRadioButton();
        jLabel32 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Doctor Appointment");

        jPanel1.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, 153, 255));
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/doctor-appointment-icon.png"))); // NOI18N
        jLabel1.setText("Doctor's Appointments");

        jSeparator1.setBackground(new java.awt.Color(102, 153, 255));
        jSeparator1.setForeground(new java.awt.Color(102, 153, 255));

        jLabel3.setFont(new java.awt.Font("SansSerif", 0, 15)); // NOI18N
        jLabel3.setText("Doctor's Name :");

        jLabel4.setFont(new java.awt.Font("SansSerif", 0, 15)); // NOI18N
        jLabel4.setText("Patient's Name :");

        patientName_textbox.setEditable(false);
        patientName_textbox.setBackground(new java.awt.Color(255, 243, 251));
        patientName_textbox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        jLabel5.setFont(new java.awt.Font("SansSerif", 0, 15)); // NOI18N
        jLabel5.setText("Visit Type :");

        record_panel.setBackground(new java.awt.Color(253, 251, 251));
        record_panel.setOpaque(false);
        record_panel.setLayout(new java.awt.BorderLayout());

        timeSlot_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        timeSlot_table.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N
        timeSlot_table.setModel(new javax.swing.table.DefaultTableModel(timeSlotData,timeSlotHeader));
        timeSlot_table.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        timeSlot_table.setRowHeight(22);
        timeSlot_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        timeSlot_table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                timeSlot_tableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(timeSlot_table);

        record_panel.add(jScrollPane1, java.awt.BorderLayout.CENTER);
        jScrollPane1.setVisible(false);

        vistType_combobox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        AutoCompleteDecorator.decorate(this.vistType_combobox);
        vistType_combobox.setModel(new javax.swing.DefaultComboBoxModel(visitTypeList));
        vistType_combobox.setNextFocusableComponent(chooseTime_combo);
        vistType_combobox.setSelectedIndex(1);
        vistType_combobox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                vistType_comboboxItemStateChanged(evt);
            }
        });

        patientcontact_textbox.setEditable(false);
        patientcontact_textbox.setBackground(new java.awt.Color(255, 243, 251));
        patientcontact_textbox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        jLabel8.setFont(new java.awt.Font("SansSerif", 0, 15)); // NOI18N
        jLabel8.setText("Contact Number:");

        jLabel9.setFont(new java.awt.Font("SansSerif", 0, 15)); // NOI18N
        jLabel9.setText("Department :");

        department_combobox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        AutoCompleteDecorator.decorate(this.department_combobox);
        department_combobox.setModel(new javax.swing.DefaultComboBoxModel(departmentList));
        //department_combobox.setSelectedIndex(CollectionUtil.getDeptIndex(departmentList,dept));
        //department_combobox.setSelectedIndex(-1);
        department_combobox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                department_comboboxItemStateChanged(evt);
            }
        });
        department_combobox.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                department_comboboxPropertyChange(evt);
            }
        });

        appointment_jcalendar.setBackground(new java.awt.Color(253, 251, 251));
        appointment_jcalendar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        appointment_jcalendar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        appointment_jcalendar.setTodayButtonVisible(true);
        appointment_jcalendar.setWeekOfYearVisible(false);
        appointment_jcalendar.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                appointment_jcalendarPropertyChange(evt);
            }
        });

        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/cancel16X16.png"))); // NOI18N
        cancel_button.setText("Cancel");
        cancel_button.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        cancel_button.setMaximumSize(new java.awt.Dimension(85, 25));
        cancel_button.setMinimumSize(new java.awt.Dimension(85, 25));
        cancel_button.setPreferredSize(new java.awt.Dimension(85, 25));
        cancel_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancel_buttonActionPerformed(evt);
            }
        });

        reset_Button.setBackground(new java.awt.Color(253, 251, 251));
        reset_Button.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        reset_Button.setForeground(new java.awt.Color(68, 62, 173));
        reset_Button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/refresh 16x16.png"))); // NOI18N
        reset_Button.setText("Reset");
        reset_Button.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        reset_Button.setMaximumSize(new java.awt.Dimension(85, 25));
        reset_Button.setMinimumSize(new java.awt.Dimension(85, 25));
        reset_Button.setPreferredSize(new java.awt.Dimension(85, 25));
        reset_Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reset_ButtonActionPerformed(evt);
            }
        });

        search_Button.setBackground(new java.awt.Color(253, 251, 251));
        search_Button.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        search_Button.setForeground(new java.awt.Color(68, 62, 173));
        search_Button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search-icon16X16.png"))); // NOI18N
        search_Button.setText("Search");
        search_Button.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        search_Button.setMaximumSize(new java.awt.Dimension(85, 25));
        search_Button.setMinimumSize(new java.awt.Dimension(85, 25));
        search_Button.setPreferredSize(new java.awt.Dimension(85, 25));
        search_Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                search_ButtonActionPerformed(evt);
            }
        });

        doctorName_combo.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        AutoCompleteDecorator.decorate(this.doctorName_combo);
        doctorName_combo.setModel(new javax.swing.DefaultComboBoxModel(doctorList));
        //doctorName_combo.setSelectedIndex(-1);
        doctorName_combo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                doctorName_comboItemStateChanged(evt);
            }
        });

        chooseTime_combo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "5", "10", "15", "20" ,"25" ,"30" ,"35" ,"40" ,"45" ,"50" ,"55" ,"60"}));
        chooseTime_combo.setVisible(false);
        chooseTime_combo.setSelectedIndex(-1);
        chooseTime_combo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                chooseTime_comboItemStateChanged(evt);
            }
        });

        chooseTime_label.setFont(new java.awt.Font("SansSerif", 0, 15)); // NOI18N
        chooseTime_label.setText("Visit Interval:");
        chooseTime_label.setVisible(false);

        opip_buttonGroup.add(ip_radiotb);
        ip_radiotb.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        ip_radiotb.setText("In Patient");
        ip_radiotb.setOpaque(false);
        ip_radiotb.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ip_radiotbMouseClicked(evt);
            }
        });
        ip_radiotb.setVisible(false);

        opip_buttonGroup.add(op_radiotb);
        op_radiotb.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        op_radiotb.setText("Out Patient");
        op_radiotb.setOpaque(false);
        op_radiotb.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                op_radiotbMouseClicked(evt);
            }
        });
        op_radiotb.setVisible(false);

        jLabel32.setFont(new java.awt.Font("SansSerif", 0, 15)); // NOI18N
        jLabel32.setText("Patient Type :");
        jLabel32.setVisible(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(9, 9, 9)
                                .addComponent(appointment_jcalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel5)
                                            .addComponent(jLabel4)
                                            .addComponent(jLabel9)
                                            .addComponent(jLabel3))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(doctorName_combo, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(129, 129, 129)
                                                .addComponent(patientName_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(129, 129, 129)
                                                .addComponent(department_combobox, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(129, 129, 129)
                                                .addComponent(vistType_combobox, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(21, 21, 21)
                                                .addComponent(jLabel32)
                                                .addGap(18, 18, 18)
                                                .addComponent(op_radiotb)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(ip_radiotb)))
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(search_Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(reset_Button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(cancel_button, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(50, 50, 50)
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(chooseTime_label)
                                                    .addComponent(jLabel8))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(patientcontact_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(chooseTime_combo, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGap(0, 99, Short.MAX_VALUE))))))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(record_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jSeparator1))))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {department_combobox, doctorName_combo, patientName_textbox, vistType_combobox});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(appointment_jcalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel8)
                                .addComponent(patientcontact_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel4)
                                    .addComponent(patientName_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel9)
                                    .addComponent(department_combobox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel3)
                                    .addComponent(doctorName_combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel5)
                                    .addComponent(vistType_combobox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(chooseTime_combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(chooseTime_label, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel32)
                                    .addComponent(op_radiotb)
                                    .addComponent(ip_radiotb)))))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cancel_button, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(search_Button, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(reset_Button, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(record_panel, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {department_combobox, doctorName_combo, patientName_textbox, patientcontact_textbox, vistType_combobox});

        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, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

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

    /**
     * Reset_ button action performed.
     *
     * @param evt the evt
     */
    private void reset_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reset_ButtonActionPerformed
        clearFields();
    }//GEN-LAST:event_reset_ButtonActionPerformed

    /**
     * Cancel_button action performed.
     *
     * @param evt the evt
     */
    private void cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel_buttonActionPerformed
        dispose();
    }//GEN-LAST:event_cancel_buttonActionPerformed

    /**
     * Search_ button action performed.
     *
     * @param evt the evt
     */
    private void search_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_search_ButtonActionPerformed
      try{
          if(validateAppointment()){
                TDoctorInformation doctor = (TDoctorInformation)doctorName_combo.getSelectedItem();
                timeSlotData = appointmentController.getAppointmentList(appointment_jcalendar.getDate(),doctorInformationController.findDoctorDetailsById(doctor.getId()));
                if(!timeSlotData.isEmpty()&&this.isVisible()){
                    getAppointmentDetails();
                }else{
                JOptionPane.showMessageDialog(null,"Doctor is not available for this day");
                clearAppointmentTable();
                }
          }
      }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"appointment"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }catch(Exception e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"appointment"}));
         }
    }//GEN-LAST:event_search_ButtonActionPerformed
        
    /**
     * Time slot_table mouse clicked.
     *
     * @param evt the evt
     */
    private void timeSlot_tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_timeSlot_tableMouseClicked
        if (evt.getClickCount() == 2) {
            int row = timeSlot_table.getSelectedRow();
            List<TAppointment> previousAppointment = new ArrayList<TAppointment>();
            TDepartmentMaster department = (TDepartmentMaster)department_combobox.getSelectedItem();
            TDoctorInformation doctor = (TDoctorInformation)doctorName_combo.getSelectedItem();
            try{
                previousAppointment = appointmentController.findPreviousAppointments(patient,appointment_jcalendar.getDate(),departmentMasterController.getDepartmentValues(department.getId()),doctorInformationController.findDoctorDetailsById(doctor.getId()),String.valueOf(vistType_combobox.getSelectedItem()));
            }catch(ProcessingException e){
                JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"appointment"}));
                throw new HealthCareException(MessageProperties.getMessage("error.dao"));
            }
            if(!previousAppointment.isEmpty()){
                if(JOptionPane.showConfirmDialog(null, "An appointment is already available for this patient. Do you want to create another one.","", JOptionPane.YES_NO_CANCEL_OPTION)==0)
                {
                    DisabledGlassPane glassPane = new DisabledGlassPane();
                    JRootPane rootPane = SwingUtilities.getRootPane(this);
                    rootPane.setGlassPane(glassPane);
                    ConfirmationDialoge confirmDialoge = new ConfirmationDialoge(MainAPP, true, showAppointmentdata(String.valueOf(timeSlot_table.getValueAt(row, 0))), oldAppointment);
                    //clearFields();
                    confirmDialoge.setResizable(false);
                    confirmDialoge.setLocationRelativeTo(null);
                    glassPane.activate("");
                    confirmDialoge.setVisible(true);
                    confirmDialoge.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                    glassPane.deactivate();
                    dispose();
                }else{
                    dispose();
                }
            }else{
                DisabledGlassPane glassPane = new DisabledGlassPane();
                JRootPane rootPane = SwingUtilities.getRootPane(this);
                    rootPane.setGlassPane(glassPane);
                    ConfirmationDialoge confirmDialoge = new ConfirmationDialoge(MainAPP, true, showAppointmentdata(String.valueOf(timeSlot_table.getValueAt(row, 0))), oldAppointment);
                    //clearFields();
                    confirmDialoge.setResizable(false);
                    confirmDialoge.setLocationRelativeTo(null);
                    glassPane.activate("");
                    confirmDialoge.setVisible(true);
                    confirmDialoge.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                    glassPane.deactivate();
                    dispose();
            }
        }
    }//GEN-LAST:event_timeSlot_tableMouseClicked

    /**
     * Department_combobox property change.
     *
     * @param evt the evt
     */
    private void department_comboboxPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_department_comboboxPropertyChange
        if(department_combobox.getSelectedItem()!=null){
            TDepartmentMaster department = (TDepartmentMaster)department_combobox.getSelectedItem();
            try {
                doctorList = doctorInformationController.getDoctorList(departmentMasterController.getDepartmentValues(department.getId()));
            }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"doctor"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }
            int index = doctorName_combo.getSelectedIndex();
            doctorName_combo.setModel(new javax.swing.DefaultComboBoxModel(doctorList));
            //doctorName_combo.setSelectedIndex(CollectionUtil.getDefaultDoctorIndex(doctorList));
            /*if(doctorList.size()>0){
                    doctorName_combo.setSelectedIndex(0);
            }else{
                    doctorName_combo.setSelectedIndex(-1);
            }*/
            if(index>=0){
                    doctorName_combo.setSelectedIndex(index);
            }else{
                 if(doctorList.size()>0){
                        doctorName_combo.setSelectedIndex(0);
                 }else{
                        doctorName_combo.setSelectedIndex(-1);
                 }
            }
            doctorList = new Vector<TDoctorInformation>();
        }
    }//GEN-LAST:event_department_comboboxPropertyChange

    /**
     * Vist type_combobox item state changed.
     *
     * @param evt the evt
     */
    private void vistType_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_vistType_comboboxItemStateChanged
        if(vistType_combobox.getSelectedItem()!=null&&vistType_combobox.getSelectedItem().toString().equalsIgnoreCase("procedure")){
            chooseTime_combo.setVisible(true);
            chooseTime_label.setVisible(true);
        }else{
            chooseTime_combo.setVisible(false);
            chooseTime_label.setVisible(false);
            chooseTime_combo.setSelectedIndex(-1);
        }
        //clearAppointmentTable();
    }//GEN-LAST:event_vistType_comboboxItemStateChanged

    /**
     * Choose time_combo item state changed.
     *
     * @param evt the evt
     */
    private void chooseTime_comboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chooseTime_comboItemStateChanged
        if(doctorName_combo.getSelectedItem()!=null){
            TDoctorInformation doctor = (TDoctorInformation)doctorName_combo.getSelectedItem();
            int doctorInterval = doctor.getDoctor_interval();
            timeRange = Integer.parseInt(chooseTime_combo.getSelectedItem().toString());
            if((timeRange < doctorInterval) || (timeRange%doctorInterval != 0)){
                JOptionPane.showMessageDialog(null,"This appointment time should be multiple of "+doctorInterval);
            }
        }
    }//GEN-LAST:event_chooseTime_comboItemStateChanged

    /**
     * Doctor name_combo item state changed.
     *
     * @param evt the evt
     */
    private void doctorName_comboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_doctorName_comboItemStateChanged
        clearAppointmentTable();
    }//GEN-LAST:event_doctorName_comboItemStateChanged

    /**
     * Department_combobox item state changed.
     *
     * @param evt the evt
     */
    private void department_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_department_comboboxItemStateChanged
        clearAppointmentTable();
    }//GEN-LAST:event_department_comboboxItemStateChanged
    
    
    /**
     * Appointment_jcalendar property change.
     *
     * @param evt the evt
     */
    private void appointment_jcalendarPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_appointment_jcalendarPropertyChange
        try{
          if(!timeSlotData.isEmpty()){  
          if(validateAppointment()){
                TDoctorInformation doctor = (TDoctorInformation)doctorName_combo.getSelectedItem();
                timeSlotData = appointmentController.getAppointmentList(appointment_jcalendar.getDate(),doctorInformationController.findDoctorDetailsById(doctor.getId()));
                if(!timeSlotData.isEmpty()){
                    getAppointmentDetails();
                }else{
                JOptionPane.showMessageDialog(null,"Doctor is not available for this day");
                clearAppointmentTable();
                }
          }
         }
      }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"appointment"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }catch(Exception e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"appointment"}));
         }
        
    }//GEN-LAST:event_appointment_jcalendarPropertyChange

    private void ip_radiotbMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ip_radiotbMouseClicked
        op_radiotb.setSelected(false);
        ip_radiotb.setSelected(true);
    }//GEN-LAST:event_ip_radiotbMouseClicked

    private void op_radiotbMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_op_radiotbMouseClicked
        op_radiotb.setSelected(true);
        ip_radiotb.setSelected(false);
    }//GEN-LAST:event_op_radiotbMouseClicked

    /** The appointment_jcalendar. */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AppointmentDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AppointmentDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AppointmentDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AppointmentDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog 
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                AppointmentDialog dialog = new AppointmentDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private static com.toedter.calendar.JCalendar appointment_jcalendar;
    private javax.swing.JButton cancel_button;
    private javax.swing.JComboBox chooseTime_combo;
    private javax.swing.JLabel chooseTime_label;
    private javax.swing.JComboBox department_combobox;
    private javax.swing.JComboBox doctorName_combo;
    private javax.swing.JRadioButton ip_radiotb;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JRadioButton op_radiotb;
    private javax.swing.ButtonGroup opip_buttonGroup;
    private javax.swing.JTextField patientName_textbox;
    private javax.swing.JTextField patientcontact_textbox;
    private javax.swing.JPanel record_panel;
    private javax.swing.JButton reset_Button;
    private javax.swing.JButton search_Button;
    private javax.swing.JTable timeSlot_table;
    private javax.swing.JComboBox vistType_combobox;
    // End of variables declaration//GEN-END:variables
    /** The time slot header. */
    private Vector<String> timeSlotHeader;
    
    /** The time slot data. */
    private Vector<Vector<String>> timeSlotData = new Vector<Vector<String>>();
    
    /** The department list. */
    private Vector<TDepartmentMaster> departmentList = new Vector<TDepartmentMaster>();
    
    /** The visit type list. */
    private Vector<TCCodeValues> visitTypeList = new Vector<TCCodeValues>();
    
    /** The doctor list. */
    private Vector<TDoctorInformation> doctorList = new Vector<TDoctorInformation>();
    
    /** The appointment controller. */
    private AppointmentController appointmentController;
    
    /** The new appointment. */
    private TAppointment newAppointment;
    
    /** The old appointment. */
    private TAppointment oldAppointment; 
    
    /** The Main app. */
    private javax.swing.JFrame MainAPP;
    
    /** The patient. */
    private TPatient patient;
    
    /** The patient controller. */
    private PatientController patientController;
    
    /** The doctor information controller. */
    private DoctorInformationController doctorInformationController;
    
    /** The department master controller. */
     private DepartmentMasterController departmentMasterController;
    
    /** The code values controller. */
    private CodeValuesController codeValuesController;
    
    /** The sdf. */
    private SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    
    /** The my pref obj. */
    private Preferences myPrefObj = Preferences.userRoot();
    
    /** The dept. */
    private String  dept;
    
    /** The time range. */
    private int timeRange;
    
    /**
     * Diplay patient info.
     *
     * @param patient the patient
     */
    private void diplayPatientInfo(TPatient patient) {
        this.patient = patient;
        String patientFullName = null;
        if(patient.getPatientMName()!=null){
                    patientFullName = patient.getPatientFName()+" "+patient.getPatientMName()+" "+patient.getPatientLName();
                }else if(patient.getPatientMName()==null){
                    patientFullName = patient.getPatientFName()+" "+patient.getPatientLName();
                }
        patientName_textbox.setText(patientFullName);
        if(patient.getPatientHtNumber()!=null){
            patientcontact_textbox.setText(String.valueOf(patient.getPatientHtNumber()));
        }
    }

    /**
     * Populate data.
     */
    private void populateData() {
        doctorInformationController = (DoctorInformationController)HealthcareLogin.context.getBean("doctorInformationController");
        appointmentController = (AppointmentController)HealthcareLogin.context.getBean("appointmentController");
        departmentMasterController=(DepartmentMasterController)HealthcareLogin.context.getBean("departmentMasterController");
        patientController = (PatientController)HealthcareLogin.context.getBean("patientController");
        codeValuesController = (CodeValuesController)HealthcareLogin.context.getBean("codeValuesController");
        newAppointment = new TAppointment();
        oldAppointment = new TAppointment();
        try{
            departmentList = departmentMasterController.getDepartmentList();
        }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"department"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }
        try{
                visitTypeList = codeValuesController.getCodeValues("Visit Type");
        }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"visit type"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }
        try{
            dept = String.valueOf(PreferenceUtil.getObject(myPrefObj, "dept"));
           
       }catch(Exception e){
            System.out.println("Exception "+e.getMessage());
        }
        timeSlotHeader = new Vector<String>();
        timeSlotHeader.add("Time Slots");
        timeSlotHeader.add("Date");
        timeSlotHeader.add("Doctor' Name");
        timeSlotHeader.add("Patient's Name");
        timeSlotHeader.add("Department");
        timeSlotHeader.add("Visit Type");
    }
    
    /**
     * Show appointmentdata.
     *
     * @param timeSlot the time slot
     * @return the t appointment
     */
    private TAppointment showAppointmentdata(String timeSlot){
        int visitNumber = 0;
        newAppointment = new TAppointment();
        newAppointment.setAppointmentDate(appointment_jcalendar.getDate());
        newAppointment.setPatientNameId(patient);
        TDepartmentMaster department = (TDepartmentMaster)department_combobox.getSelectedItem();
        try{
        newAppointment.setDepartmentNameId(departmentMasterController.getDepartmentValues(department.getId()));
        }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"patient"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }
        TDoctorInformation doctor = (TDoctorInformation)doctorName_combo.getSelectedItem();
        try{
        newAppointment.setDoctorNameId(doctorInformationController.findDoctorDetailsById(doctor.getId()));
        }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"patient"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }
        newAppointment.setVisitType(String.valueOf(vistType_combobox.getSelectedItem()));
        if(chooseTime_combo.getSelectedItem()!=null){
        newAppointment.setVisitInterval(Integer.parseInt(String.valueOf(chooseTime_combo.getSelectedItem())));
        }else{
        newAppointment.setVisitInterval(null);
        }
        newAppointment.setAppointmentTime(timeSlot);
        try{
                visitNumber = appointmentController.getVisitOccurance(patient);
        }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"visit type"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }
        if(op_radiotb.isSelected()){
             newAppointment.setScheduleType("Out Patient");
        }else if(ip_radiotb.isSelected()){
             newAppointment.setScheduleType("In Patient");
        }else{
             newAppointment.setScheduleType("Out Patient");
        }
        newAppointment.setVisitNumber(visitNumber+1);
        return newAppointment;
    }

    /**
     * Diplay appoiment info.
     *
     * @param appointment the appointment
     */
    private void diplayAppoimentInfo(TAppointment appointment) {
        if(appointment!=null){
        this.oldAppointment = appointment;
        appointment_jcalendar.setDate(appointment.getAppointmentDate());
        try{
            diplayPatientInfo(appointment.getPatientNameId());
        
            
            if(appointment.getDepartmentNameId() != null){
                department_combobox.setSelectedIndex(CollectionUtil.getDepartmentIndex(departmentList, appointment.getDepartmentNameId().getId()));
                if(appointment.getDoctorNameId() != null){
                    TDepartmentMaster department = (TDepartmentMaster)department_combobox.getSelectedItem();
                    doctorList = doctorInformationController.getDoctorList(departmentMasterController.getDepartmentValues(department.getId()));
                    doctorName_combo.setModel(new javax.swing.DefaultComboBoxModel(doctorList));
                    doctorName_combo.setSelectedIndex(CollectionUtil.getDoctorIndex(doctorList, appointment.getDoctorNameId().getId()));
                }
            }
            vistType_combobox.setSelectedIndex(CollectionUtil.getCodeValueIndex(visitTypeList,appointment.getVisitType()));
            if(oldAppointment.getScheduleType().equalsIgnoreCase("Out Patient")){
                op_radiotb.setSelected(true);
            }else if(oldAppointment.getScheduleType().equalsIgnoreCase("In Patient")){
                ip_radiotb.setSelected(true);
            }
        }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"patient"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }
        
    }}

    /**
     * Clear fields.
     */
    private void clearFields() {
        clearAppointmentTable();
        department_combobox.setSelectedIndex(-1);
        doctorName_combo.setSelectedIndex(-1);
        vistType_combobox.setSelectedIndex(-1);
        appointment_jcalendar.setDate(new Date());
        newAppointment = new TAppointment();
        oldAppointment = new TAppointment();
        opip_buttonGroup.clearSelection();
    }
    
    /**
     * Validate appointment.
     *
     * @return true, if successful
     */
    private boolean validateAppointment(){
       boolean valid = true;
       //Date curdate = new Date();
       try{
       /*if(sdf.parse(sdf.format(appointment_jcalendar.getDate())).before(sdf.parse(sdf.format(curdate)))&&this.isVisible()){
           clearAppointmentTable();
           JOptionPane.showMessageDialog(null, "User cannot make appointments for past dates");
           valid = false;
       }else */if(this.department_combobox.getSelectedItem() == null){
           JOptionPane.showMessageDialog(null, MessageProperties.getMessage("component.selected",new Object[]{"Department"}), "Error", JOptionPane.ERROR_MESSAGE);
           department_combobox.requestFocus();
            valid = false;
       }else if(this.doctorName_combo.getSelectedItem() == null){
           JOptionPane.showMessageDialog(null, MessageProperties.getMessage("component.selected",new Object[]{"Doctor Name"}), "Error", JOptionPane.ERROR_MESSAGE);
            doctorName_combo.requestFocus();
            valid = false;
       }else if(this.vistType_combobox.getSelectedItem() == null){
           JOptionPane.showMessageDialog(null, MessageProperties.getMessage("component.selected",new Object[]{"Visit Type"}), "Error", JOptionPane.ERROR_MESSAGE);
           vistType_combobox.requestFocus();
            valid = false;
       }else if(vistType_combobox.getSelectedItem().toString().equalsIgnoreCase("procedure") && this.chooseTime_combo.getSelectedItem() == null){
           JOptionPane.showMessageDialog(null, MessageProperties.getMessage("component.selected",new Object[]{"Visit Interval"}), "Error", JOptionPane.ERROR_MESSAGE);
           chooseTime_combo.requestFocus();
            valid = false;
       }
       }catch(Exception e){}
       return valid;
    }
    
    /**
     * Gets the appointment details.
     *
     * @return the appointment details
     */
    private void getAppointmentDetails(){
       //timeSlotData.clear();
       timeSlot_table.setModel(new javax.swing.table.DefaultTableModel(timeSlotData,timeSlotHeader));
       timeSlot_table.getColumnModel().getColumn(0).setPreferredWidth(100);
       timeSlot_table.getColumnModel().getColumn(0).setMaxWidth(100);
       timeSlot_table.getColumnModel().getColumn(1).setPreferredWidth(100);
       timeSlot_table.getColumnModel().getColumn(1).setMaxWidth(100);
       timeSlot_table.getColumnModel().getColumn(2).setPreferredWidth(230);
       timeSlot_table.getColumnModel().getColumn(2).setMaxWidth(230);
       timeSlot_table.getColumnModel().getColumn(3).setPreferredWidth(230);
       timeSlot_table.getColumnModel().getColumn(3).setMaxWidth(230);
       timeSlot_table.getColumnModel().getColumn(4).setPreferredWidth(180);
       timeSlot_table.getColumnModel().getColumn(4).setMaxWidth(180);
       jScrollPane1.setVisible(true);
       jPanel1.updateUI();
    }
    
    /**
     * Clear appointment table.
     */
    private void clearAppointmentTable(){
        jScrollPane1.setVisible(false);
        //jPanel1.updateUI();
        //timeSlotData.clear();
    }
    
}

Commits for Pharmacy_09_03_18/Dr Gyana ProjectSpace/DrGyanaEMR/src/main/java/com/bestray/healthcareemr/Views/AppointmentDialog.java

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