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
/*
 * 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.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.TimeRange;
import com.bestray.healthcarecommonutil.vo.TCCodeValues;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

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

    /**
     * Creates new form AppointmentRecurrenceDialog.
     *
     * @param parent the parent
     * @param modal the modal
     */
    public AppointmentRecurrenceDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        populateData();
        initComponents();
    }
    
    /**
     * Instantiates a new appointment recurrence dialog.
     *
     * @param parent the parent
     * @param modal the modal
     * @param appointment the appointment
     */
    public AppointmentRecurrenceDialog(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() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        patientName_textbox = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        department_combobox = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        vistType_combobox = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        vistTime_combobox = new javax.swing.JComboBox();
        doctorName_combo = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        daily_radioBt = new javax.swing.JRadioButton();
        weekly_radioBt = new javax.swing.JRadioButton();
        monthly_radioBt = new javax.swing.JRadioButton();
        yearly_radioBt = new javax.swing.JRadioButton();
        jPanel4 = new javax.swing.JPanel();
        endBy_datePicker = new org.jdesktop.swingx.JXDatePicker();
        endAfter_radioBt = new javax.swing.JRadioButton();
        endBy_radioBt = new javax.swing.JRadioButton();
        occurence_number_textbox = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        save_Button = new javax.swing.JButton();
        cancel_button = new javax.swing.JButton();

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

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

        jPanel2.setBackground(new java.awt.Color(253, 251, 251));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Appointment Details", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("SansSerif", 0, 10), new java.awt.Color(80, 98, 242))); // NOI18N

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

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

        jLabel9.setFont(new java.awt.Font("SansSerif", 0, 11)); // 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(-1);
        department_combobox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                department_comboboxItemStateChanged(evt);
            }
        });

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

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

        vistType_combobox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        vistType_combobox.setModel(new javax.swing.DefaultComboBoxModel(visitTypeList));
        vistType_combobox.setSelectedIndex(-1);

        jLabel6.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        jLabel6.setText("Visit Time :");

        vistTime_combobox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        AutoCompleteDecorator.decorate(this.vistTime_combobox);
        vistTime_combobox.setModel(new javax.swing.DefaultComboBoxModel(timeRangeList));
        vistType_combobox.setSelectedIndex(-1);

        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);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel9)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(vistTime_combobox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(department_combobox, javax.swing.GroupLayout.Alignment.LEADING, 0, 180, Short.MAX_VALUE)
                    .addComponent(vistType_combobox, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(patientName_textbox, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(doctorName_combo, javax.swing.GroupLayout.Alignment.LEADING, 0, 180, Short.MAX_VALUE))
                .addContainerGap(262, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.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.RELATED)
                .addGroup(jPanel2Layout.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.RELATED)
                .addGroup(jPanel2Layout.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.RELATED)
                .addGroup(jPanel2Layout.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))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(vistTime_combobox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel3.setBackground(new java.awt.Color(253, 251, 251));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Recurrence Pattern", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("SansSerif", 0, 10), new java.awt.Color(80, 98, 242))); // NOI18N

        daily_radioBt.setBackground(new java.awt.Color(253, 251, 251));
        buttonGroup1.add(daily_radioBt);
        daily_radioBt.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        daily_radioBt.setText("Daily");
        daily_radioBt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                daily_radioBtActionPerformed(evt);
            }
        });

        weekly_radioBt.setBackground(new java.awt.Color(253, 251, 251));
        buttonGroup1.add(weekly_radioBt);
        weekly_radioBt.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        weekly_radioBt.setText("Weekly");
        weekly_radioBt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                weekly_radioBtActionPerformed(evt);
            }
        });

        monthly_radioBt.setBackground(new java.awt.Color(253, 251, 251));
        buttonGroup1.add(monthly_radioBt);
        monthly_radioBt.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        monthly_radioBt.setText("Monthly");
        monthly_radioBt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                monthly_radioBtActionPerformed(evt);
            }
        });

        yearly_radioBt.setBackground(new java.awt.Color(253, 251, 251));
        buttonGroup1.add(yearly_radioBt);
        yearly_radioBt.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        yearly_radioBt.setText("Yearly");
        yearly_radioBt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                yearly_radioBtActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(daily_radioBt)
                .addGap(18, 18, 18)
                .addComponent(weekly_radioBt)
                .addGap(18, 18, 18)
                .addComponent(monthly_radioBt)
                .addGap(18, 18, 18)
                .addComponent(yearly_radioBt)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(daily_radioBt)
                    .addComponent(weekly_radioBt)
                    .addComponent(monthly_radioBt)
                    .addComponent(yearly_radioBt))
                .addContainerGap())
        );

        jPanel4.setBackground(new java.awt.Color(253, 251, 251));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Recurrence Range", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("SansSerif", 0, 10), new java.awt.Color(80, 98, 242))); // NOI18N

        endBy_datePicker.setFormats(new String[] { "dd/MM/yyyy" });

        endAfter_radioBt.setBackground(new java.awt.Color(253, 251, 251));
        buttonGroup2.add(endAfter_radioBt);
        endAfter_radioBt.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        endAfter_radioBt.setText("End after :");
        endAfter_radioBt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endAfter_radioBtActionPerformed(evt);
            }
        });

        endBy_radioBt.setBackground(new java.awt.Color(253, 251, 251));
        buttonGroup2.add(endBy_radioBt);
        endBy_radioBt.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        endBy_radioBt.setText("End by :");
        endBy_radioBt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endBy_radioBtActionPerformed(evt);
            }
        });

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

        jLabel7.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        jLabel7.setText("Occurrence");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(endAfter_radioBt)
                    .addComponent(endBy_radioBt))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(occurence_number_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7))
                    .addComponent(endBy_datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(endAfter_radioBt)
                    .addComponent(occurence_number_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(endBy_radioBt)
                    .addComponent(endBy_datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        save_Button.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        save_Button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save-icon 16X16.png"))); // NOI18N
        save_Button.setText("Save");
        save_Button.setMaximumSize(new java.awt.Dimension(85, 25));
        save_Button.setMinimumSize(new java.awt.Dimension(85, 25));
        save_Button.setPreferredSize(new java.awt.Dimension(85, 25));
        save_Button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                save_ButtonActionPerformed(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);
            }
        });

        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(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(334, 334, 334)
                        .addComponent(save_Button, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancel_button, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, 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(save_Button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cancel_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

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

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

    /**
     * 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

    /**
     * Save_ button action performed.
     *
     * @param evt the evt
     */
    private void save_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save_ButtonActionPerformed
        try{
            appointment = new TAppointment();
            appointment.setPatientNameId(patient);
            TDepartmentMaster department = (TDepartmentMaster)department_combobox.getSelectedItem();
            appointment.setDepartmentNameId(departmentMasterController.getDepartmentValues(department.getId()));
            TDoctorInformation doctor = (TDoctorInformation)doctorName_combo.getSelectedItem();
            appointment.setDoctorNameId(doctorInformationController.findDoctorDetailsById(doctor.getId()));
            appointment.setVisitType(String.valueOf(vistType_combobox.getSelectedItem()));
            appointment.setAppointmentTime(String.valueOf(vistTime_combobox.getSelectedItem()));
            List<Date> dateList = new ArrayList<Date>();
            if(endAfter_radioBt.isSelected()){
            dateList = getDateList(recurrencePattern, Integer.parseInt(occurence_number_textbox.getText()));
            }else if(endBy_radioBt.isSelected()){
            dateList = getDateList(recurrencePattern, getOccurenceCount(new Date(), endBy_datePicker.getDate()));
            }
            appointmentController.saveNextAppointments(appointment,dateList);
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("success.save",new Object[]{"Next Appointment"}));
            dispose();
        }catch(ProcessingException e){
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Next Appointment"}));
                throw new HealthCareException(MessageProperties.getMessage("error.dao"));
           }catch(Exception e){
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Next Appointment"}));
           }
    }//GEN-LAST:event_save_ButtonActionPerformed

    /**
     * Daily_radio bt action performed.
     *
     * @param evt the evt
     */
    private void daily_radioBtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_daily_radioBtActionPerformed
        recurrencePattern = "Daily";
    }//GEN-LAST:event_daily_radioBtActionPerformed

    /**
     * Weekly_radio bt action performed.
     *
     * @param evt the evt
     */
    private void weekly_radioBtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_weekly_radioBtActionPerformed
        recurrencePattern = "Weekly";
    }//GEN-LAST:event_weekly_radioBtActionPerformed

    /**
     * Monthly_radio bt action performed.
     *
     * @param evt the evt
     */
    private void monthly_radioBtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_monthly_radioBtActionPerformed
        recurrencePattern = "Monthly";
    }//GEN-LAST:event_monthly_radioBtActionPerformed

    /**
     * Yearly_radio bt action performed.
     *
     * @param evt the evt
     */
    private void yearly_radioBtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yearly_radioBtActionPerformed
        recurrencePattern = "Yearly";
    }//GEN-LAST:event_yearly_radioBtActionPerformed

    /**
     * End after_radio bt action performed.
     *
     * @param evt the evt
     */
    private void endAfter_radioBtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_endAfter_radioBtActionPerformed
        endBy_datePicker.setDate(null);
        endBy_datePicker.setEnabled(false);
        occurence_number_textbox.setEditable(true);
    }//GEN-LAST:event_endAfter_radioBtActionPerformed

    /**
     * End by_radio bt action performed.
     *
     * @param evt the evt
     */
    private void endBy_radioBtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_endBy_radioBtActionPerformed
        endBy_datePicker.setEnabled(true);
        occurence_number_textbox.setText("");
        occurence_number_textbox.setEditable(false);
    }//GEN-LAST:event_endBy_radioBtActionPerformed

    /**
     * Department_combobox item state changed.
     *
     * @param evt the evt
     */
    private void department_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_department_comboboxItemStateChanged
        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"));
         }
            doctorName_combo.setModel(new javax.swing.DefaultComboBoxModel(doctorList));
            doctorList = new Vector<TDoctorInformation>();
        }
    }//GEN-LAST:event_department_comboboxItemStateChanged

    /** The button group1. @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    
    /** The button group2. */
    private javax.swing.ButtonGroup buttonGroup2;
    
    /** The cancel_button. */
    private javax.swing.JButton cancel_button;
    
    /** The daily_radio bt. */
    private javax.swing.JRadioButton daily_radioBt;
    
    /** The department_combobox. */
    private javax.swing.JComboBox department_combobox;
    
    /** The doctor name_combo. */
    private javax.swing.JComboBox doctorName_combo;
    
    /** The end after_radio bt. */
    private javax.swing.JRadioButton endAfter_radioBt;
    
    /** The end by_date picker. */
    private org.jdesktop.swingx.JXDatePicker endBy_datePicker;
    
    /** The end by_radio bt. */
    private javax.swing.JRadioButton endBy_radioBt;
    
    /** The j label3. */
    private javax.swing.JLabel jLabel3;
    
    /** The j label4. */
    private javax.swing.JLabel jLabel4;
    
    /** The j label5. */
    private javax.swing.JLabel jLabel5;
    
    /** The j label6. */
    private javax.swing.JLabel jLabel6;
    
    /** The j label7. */
    private javax.swing.JLabel jLabel7;
    
    /** The j label9. */
    private javax.swing.JLabel jLabel9;
    
    /** The j panel1. */
    private javax.swing.JPanel jPanel1;
    
    /** The j panel2. */
    private javax.swing.JPanel jPanel2;
    
    /** The j panel3. */
    private javax.swing.JPanel jPanel3;
    
    /** The j panel4. */
    private javax.swing.JPanel jPanel4;
    
    /** The monthly_radio bt. */
    private javax.swing.JRadioButton monthly_radioBt;
    
    /** The occurence_number_textbox. */
    private javax.swing.JTextField occurence_number_textbox;
    
    /** The patient name_textbox. */
    private javax.swing.JTextField patientName_textbox;
    
    /** The save_ button. */
    private javax.swing.JButton save_Button;
    
    /** The vist time_combobox. */
    private javax.swing.JComboBox vistTime_combobox;
    
    /** The vist type_combobox. */
    private javax.swing.JComboBox vistType_combobox;
    
    /** The weekly_radio bt. */
    private javax.swing.JRadioButton weekly_radioBt;
    
    /** The yearly_radio bt. */
    private javax.swing.JRadioButton yearly_radioBt;
    // End of variables declaration//GEN-END:variables
    /** The department list. */
    private Vector<TDepartmentMaster> departmentList = new Vector<TDepartmentMaster>();
    
    /** The doctor list. */
    private Vector<TDoctorInformation> doctorList = new Vector<TDoctorInformation>();
    
    /** The time range list. */
    private Vector<String> timeRangeList = new Vector<String>();
    
    /** The appointment. */
    private TAppointment appointment;
    
    /** The patient. */
    private TPatient patient;
    
    /** The recurrence pattern. */
    private String recurrencePattern;
    
    /** The patient controller. */
    private PatientController patientController;
    
    /** The appointment controller. */
    private AppointmentController appointmentController;
    
    /** The doctor information controller. */
    private DoctorInformationController doctorInformationController;
    
    /** The visit type list. */
    private Vector<TCCodeValues> visitTypeList = new Vector<TCCodeValues>();
    
    /** The code values controller. */
    private CodeValuesController codeValuesController;
    
    /** The department master controller. */
     private DepartmentMasterController departmentMasterController;
    
    /**
     * Populate data.
     */
    private void populateData(){
        doctorInformationController = (DoctorInformationController)HealthcareLogin.context.getBean("doctorInformationController");
        departmentMasterController=(DepartmentMasterController)HealthcareLogin.context.getBean("departmentMasterController");
        appointmentController = (AppointmentController)HealthcareLogin.context.getBean("appointmentController");
        patientController = (PatientController)HealthcareLogin.context.getBean("patientController");
        codeValuesController = (CodeValuesController)HealthcareLogin.context.getBean("codeValuesController");
        appointment = 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"));
         }
        List<String> timeslots = TimeRange.getTimeSlot("12:00 AM", "24:30 PM", 20);
        for(String timeslot:timeslots){
            timeRangeList.add(timeslot);
        }
    }
    
     /**
      * Diplay appoiment info.
      *
      * @param appointment the appointment
      */
     private void diplayAppoimentInfo(TAppointment appointment) {
         if(appointment!=null){
             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()));
                    System.out.println(doctorList.size());
                doctorName_combo.setSelectedIndex(CollectionUtil.getDoctorIndex(doctorList, appointment.getDoctorNameId().getId()));
                }
            }
            //vistType_combobox.setSelectedItem(appointment.getVisitType());
            vistType_combobox.setSelectedIndex(CollectionUtil.getCodeValueIndex(visitTypeList,appointment.getVisitType()));
            vistTime_combobox.setSelectedItem(appointment.getAppointmentTime());
            }catch(ProcessingException e){
                JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"patient"}));
                throw new HealthCareException(MessageProperties.getMessage("error.dao"));
             }
         }
     }
     
     /**
      * 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);
     }
     
     /**
      * Gets the date list.
      *
      * @param recurrencePattern the recurrence pattern
      * @param occurrence the occurrence
      * @return the date list
      */
     private List<Date> getDateList(String recurrencePattern, int occurrence){
         
         List<Date> dateList=new ArrayList<Date>();
         int interval=0;
         Date currDate=new Date();
         Date adate=currDate;
         if(recurrencePattern.equalsIgnoreCase("Daily")){
             interval=1;
         }
         else if(recurrencePattern.equalsIgnoreCase("Weekly")){
             interval=7;
         }
         else if(recurrencePattern.equalsIgnoreCase("Monthly")){
             interval=30;
         }
         else if(recurrencePattern.equalsIgnoreCase("Yearly")){
             interval=365;
         }
         Calendar calNextJob  = Calendar.getInstance();
         calNextJob.setTime(currDate);
         for(int i=0;i<occurrence;i++){
            calNextJob.add(Calendar.DATE, interval);
            adate=calNextJob.getTime();
            
            dateList.add(adate);
         }
         return dateList;
     }
     
     /**
      * Gets the occurence count.
      *
      * @param checkOutDate the check out date
      * @param endDate the end date
      * @return the occurence count
      */
     private int getOccurenceCount(Date checkOutDate,Date endDate){
         int dateDuration = (int) ((endDate.getTime() - checkOutDate.getTime()) / (1000 * 60 * 60 * 24));
         int interval = 0;
         int occurence = 0;
         if(recurrencePattern.equalsIgnoreCase("Daily")){
             interval=1;
             occurence = (dateDuration/interval)+1;
         }
         else if(recurrencePattern.equalsIgnoreCase("Weekly")){
             interval=7;
             occurence = dateDuration/interval;
         }
         else if(recurrencePattern.equalsIgnoreCase("Monthly")){
             interval=30;
             occurence = dateDuration/interval;
         }
         else if(recurrencePattern.equalsIgnoreCase("Yearly")){
             interval=365;
             occurence = dateDuration/interval;
         }
         
         return occurence;
        
     }
     
}

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

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