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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bestray.healthcarecommonutil.views;

import com.bestray.healthcarecommonutil.ContextLoading;
import com.bestray.healthcarecommonutil.controller.LabReceiptController;
import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.report.LabReceipt;
import com.bestray.healthcarecommonutil.util.ButtonType;
import com.bestray.healthcarecommonutil.util.CurvedGradientPanel;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.StandardButton;
import com.bestray.healthcarecommonutil.util.Theme;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcarecommonutil.vo.TPatLabReceipt;
import com.bestray.healthcarecommonutil.vo.TPatient;
import com.bestray.healthcarecommonutil.util.Initcap;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import com.bestray.healthcarecommonutil.util.TimeRange;
import com.bestray.healthcarecommonutil.vo.TEncounterProcedure;
import com.bestray.healthcarecommonutil.vo.TPatientEncounter;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.DefaultCellEditor;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;

/**
 *
 * @author User1
 */
public class LabReceiptDialog1 extends javax.swing.JDialog {

    /**
     * Creates new form LabReceiptDialog
     */
    public LabReceiptDialog1(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    public LabReceiptDialog1(java.awt.Frame parent, boolean modal, TPatient patientInfo, TPatientEncounter enc) {
        super(parent, modal);
        populateData();
        initComponents();
        showPatientInfo(patientInfo);
        this.encounter = enc;
        showSelectedProcedures(encounter);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new SimpleGradientPanel(Color.WHITE,Color.LIGHT_GRAY);
        jPanel2 = new javax.swing.JPanel();
        jLabel38 = new javax.swing.JLabel();
        patientidlabel = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        namelabel = new javax.swing.JLabel();
        sexlabel = new javax.swing.JLabel();
        agelabel = new javax.swing.JLabel();
        doblabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        contactnumberlabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        addresslabel = new javax.swing.JLabel();
        jButton1 = new StandardButton("Close",Theme.STANDARD_RED_THEME,ButtonType.BUTTON_RECTANGULAR);
        jPanel3 = new CurvedGradientPanel();
        jLabel39 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        duePrice_textbox = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        comment_taxtArea = new javax.swing.JTextArea();
        jLabel13 = new javax.swing.JLabel();
        receivedBy_textbox = new javax.swing.JTextField();
        star_label = new javax.swing.JLabel();
        adjustment_textbox = new javax.swing.JTextField();
        totalPrice_textbox = new javax.swing.JTextField();
        receivedNumber_textbox = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        mandatoryStar_label = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        paidPrice_textbox = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        orderPrice_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;
            }

        };
        jLabel4 = new javax.swing.JLabel();
        save_button = new StandardButton("Save & Print",Theme.STANDARD_ORANGE_THEME,ButtonType.BUTTON_RECTANGULAR);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setUndecorated(true);

        jPanel2.setBackground(new java.awt.Color(255, 255, 204));
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel38.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel38.setText("Patient ID :");

        patientidlabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        patientidlabel.setText("patientId");

        jLabel3.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel3.setText("Name :");

        jLabel9.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel9.setText("Sex :");

        jLabel7.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel7.setText("Age :");

        jLabel11.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel11.setText("DOB :");

        namelabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        namelabel.setText("jLabel1");

        sexlabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        sexlabel.setText("jLabel1");

        agelabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        agelabel.setText("jLabel1");

        doblabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        doblabel.setText("jLabel1");

        jLabel1.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel1.setText("Contact Number :");

        contactnumberlabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        contactnumberlabel.setText("jLabel2");

        jLabel2.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel2.setText("Address :");

        addresslabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        addresslabel.setText("jLabel5");

        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)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(namelabel, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel38)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(patientidlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(contactnumberlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(addresslabel, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sexlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(95, 95, 95)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(doblabel, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(33, 33, 33)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(agelabel, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(105, 105, 105))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel38)
                    .addComponent(patientidlabel)
                    .addComponent(jLabel9)
                    .addComponent(sexlabel)
                    .addComponent(jLabel11)
                    .addComponent(doblabel)
                    .addComponent(jLabel7)
                    .addComponent(agelabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(contactnumberlabel)
                    .addComponent(jLabel2)
                    .addComponent(addresslabel)
                    .addComponent(jLabel3)
                    .addComponent(namelabel))
                .addContainerGap())
        );

        jButton1.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        jButton1.setText("Close");
        jButton1.setOpaque(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

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

        jLabel39.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel39.setText("Lab Orders :");

        jLabel6.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel6.setText("Total Amount :");

        jLabel8.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel8.setText("Due Amount :");

        duePrice_textbox.setBackground(new java.awt.Color(255, 243, 251));
        duePrice_textbox.setFont(new java.awt.Font("SansSerif", 0, 13)); // NOI18N
        duePrice_textbox.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                duePrice_textboxKeyReleased(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel10.setText("Adjustment :");

        jLabel12.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel12.setText("Comments :");

        comment_taxtArea.setColumns(20);
        comment_taxtArea.setRows(5);
        jScrollPane2.setViewportView(comment_taxtArea);

        jLabel13.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel13.setText("Received By :");

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

        star_label.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        star_label.setForeground(new java.awt.Color(255, 0, 0));
        star_label.setText("*");
        star_label.setVisible(false);

        adjustment_textbox.setEditable(false);
        adjustment_textbox.setBackground(new java.awt.Color(255, 243, 251));
        adjustment_textbox.setFont(new java.awt.Font("SansSerif", 0, 13)); // NOI18N
        adjustment_textbox.setBorder(null);
        adjustment_textbox.setOpaque(false);

        totalPrice_textbox.setEditable(false);
        totalPrice_textbox.setBackground(new java.awt.Color(255, 243, 251));
        totalPrice_textbox.setFont(new java.awt.Font("SansSerif", 0, 13)); // NOI18N
        totalPrice_textbox.setBorder(null);
        totalPrice_textbox.setOpaque(false);

        receivedNumber_textbox.setEditable(false);
        receivedNumber_textbox.setBackground(new java.awt.Color(255, 243, 251));
        receivedNumber_textbox.setFont(new java.awt.Font("SansSerif", 0, 13)); // NOI18N
        receivedNumber_textbox.setForeground(new java.awt.Color(255, 0, 0));
        receivedNumber_textbox.setBorder(null);
        receivedNumber_textbox.setOpaque(false);

        jLabel14.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel14.setText("Receipt # :");

        mandatoryStar_label.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        mandatoryStar_label.setForeground(new java.awt.Color(255, 0, 0));
        mandatoryStar_label.setText("*");
        star_label.setVisible(false);

        jLabel5.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel5.setText("Paid Amount :");

        paidPrice_textbox.setEditable(false);

        orderPrice_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        orderPrice_table.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        orderPrice_table.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {

        },
        new String [] {
            "Select", "Patient Id", "First Name", "Middle Name", "Last Name", "Gender", "Date Of Birth", "Joined Date", "Contact No", "Id"
        }
    ) {
        Class[] types = new Class [] {
            java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
        };
        boolean[] canEdit = new boolean [] {
            false, false, false, false, false, false, false, false, false, false
        };

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

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit [columnIndex];
        }
    });
    orderPrice_table.setRowHeight(20);
    orderPrice_table.setShowHorizontalLines(false);
    orderPrice_table.setShowVerticalLines(false);
    orderPrice_table.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            orderPrice_tableMouseClicked(evt);
        }
    });
    jScrollPane1.setViewportView(orderPrice_table);

    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()
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel39)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel12)
                        .addComponent(jLabel13)
                        .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addComponent(receivedBy_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, Short.MAX_VALUE))
                                .addComponent(jScrollPane2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(star_label))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(totalPrice_textbox, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                                        .addComponent(paidPrice_textbox))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel3Layout.createSequentialGroup()
                                            .addComponent(mandatoryStar_label)
                                            .addGap(0, 0, 0)
                                            .addComponent(jLabel8)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(duePrice_textbox, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))
                                        .addGroup(jPanel3Layout.createSequentialGroup()
                                            .addComponent(jLabel10)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(adjustment_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addComponent(receivedNumber_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 0, Short.MAX_VALUE)))))
            .addGap(16, 16, 16))
    );

    jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {adjustment_textbox, duePrice_textbox, totalPrice_textbox});

    jPanel3Layout.setVerticalGroup(
        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel3Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel39)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(receivedNumber_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel14))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(totalPrice_textbox)
                        .addComponent(adjustment_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(paidPrice_textbox, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(duePrice_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(mandatoryStar_label)
                            .addComponent(jLabel5)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel12)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(star_label))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(receivedBy_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13))
                    .addGap(48, 48, 48))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(39, 39, 39))))
    );

    jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {adjustment_textbox, duePrice_textbox, receivedBy_textbox, receivedNumber_textbox, totalPrice_textbox});

    jLabel4.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
    jLabel4.setForeground(new java.awt.Color(102, 153, 255));
    jLabel4.setText("  Lab Order Receipt :");

    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 & Print");
    save_button.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            save_buttonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addComponent(jLabel4)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(save_button)))
            .addContainerGap())
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(5, 5, 5)
                    .addComponent(jLabel4))
                .addComponent(jButton1))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .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, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(save_button)
            .addContainerGap())
    );

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

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

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

    private void save_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save_buttonActionPerformed
        try{
            String procedure_master_id = "";
            if(validateReceiptSave()){
                List<TEncounterProcedure> updatedencproList = new ArrayList<TEncounterProcedure>();
                     for(int i = 0; i<orderPrice_table.getRowCount();i++){
                         TEncounterProcedure encprocedure = (TEncounterProcedure)orderPrice_table.getValueAt(i, 1);
                         boolean val = (boolean)orderPrice_table.getValueAt(i, 0);
                         if(val){
                             encprocedure.setPaymentStatus("PAID");
                             procedure_master_id = procedure_master_id.concat(encprocedure.getProcedure().getId().toString()).concat(",");
                             updatedencproList.add(encprocedure);
                         }
                     }
                 /*if(labReceipt!=null){
                    labReceipt.setTotalTrice(totalPrice_textbox.getText());
                    labReceipt.setPaidPrice(String.valueOf(Double.parseDouble(paidPrice_textbox.getText())+Double.parseDouble(duePrice_textbox.getText())));
                    labReceipt.setAdjustmentAmount(adjustment_textbox.getText());
                    labReceipt.setComments(comment_taxtArea.getText());
                    labReceipt.setReceivedBy(receivedBy_textbox.getText());
                    Long ID = labReceiptController.saveReceiptDetails(labReceipt);
                    JOptionPane.showMessageDialog(null, "Information saved and printing receipt.");
                    //For Lab Receipt Print
                    LabReceipt labreceipt = new LabReceipt();
                    
                    String receipt_id = String.valueOf(labReceipt.getId());
                    int lastIndex = procedure_master_id.lastIndexOf(",");
                    String orderid = procedure_master_id.substring(0, lastIndex);
                    String patientName = namelabel.getText();
                     labreceipt.getPdfReport(receipt_id, orderid,patientName);
                     labreceipt.openPdfReport();
                           
             }else{*/
                    labReceipt = new TPatLabReceipt();
                    labReceipt.setReceiptNumber(receivedNumber_textbox.getText());
                    labReceipt.setPatientId(patientinfo);
                    labReceipt.setTotalTrice(totalPrice_textbox.getText());
                    labReceipt.setPaidPrice(String.valueOf(Double.parseDouble(paidPrice_textbox.getText())+Double.parseDouble(duePrice_textbox.getText())));
                    labReceipt.setAdjustmentAmount(adjustment_textbox.getText());
                    labReceipt.setComments(comment_taxtArea.getText());
                    labReceipt.setReceivedBy(receivedBy_textbox.getText());
                    labReceipt.setEncounterId(encounter);
                    savedReceiptID = labReceiptController.saveReceiptDetails(labReceipt);
                    JOptionPane.showMessageDialog(null, "Information saved and printing receipt.");

                    //For Lab Receipt Print
                    LabReceipt labreceipt = new LabReceipt();
                    String receipt_id = String.valueOf(savedReceiptID);
                    int lastIndex = procedure_master_id.lastIndexOf(",");
                    String orderid = procedure_master_id.substring(0, lastIndex);
                    String patientName = namelabel.getText();
                     labreceipt.getPdfReport(receipt_id, orderid,patientName);
                    labreceipt.openPdfReport();
                    
               //}
                 
                 labReceiptController.updateEncProcedureList(updatedencproList);
                 
               }else{
                     JOptionPane.showMessageDialog(null, "Information not saved.");
               }
           }catch(HibernateOptimisticLockingFailureException e){
                 JOptionPane.showMessageDialog(null, "Error in updating Lab Receipt");
           }catch(ProcessingException e){
                 JOptionPane.showMessageDialog(null, "Error in saving Receipt");
                 throw new HealthCareException("Database intercation problem");
           }catch(Exception e){
                 JOptionPane.showMessageDialog(null, "Error in saving Receipt");
           }
    }//GEN-LAST:event_save_buttonActionPerformed

    private void duePrice_textboxKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_duePrice_textboxKeyReleased
         Double remaining = 0d;
        if(validateAmountPaid()){
            if(paidPrice_textbox.getText().length()>0){
                remaining=Double.parseDouble(totalPrice_textbox.getText())-Double.parseDouble(paidPrice_textbox.getText())-Double.parseDouble(duePrice_textbox.getText());
            }else{
                remaining=Double.parseDouble(duePrice_textbox.getText());
            }
        
        adjustment_textbox.setText(String.valueOf(remaining));
        if(remaining!=0){
            star_label.setVisible(true);
        }else{
            star_label.setVisible(false);
        }
      }
    }//GEN-LAST:event_duePrice_textboxKeyReleased

    private void orderPrice_tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_orderPrice_tableMouseClicked
        if(evt.getClickCount()==1){
            if(orderPrice_table!=null){
                int row = orderPrice_table.getSelectedRow();
                    if(orderPrice_table.getValueAt(row, 0).equals(false)){
                        orderPrice_table.setValueAt(true, row, 0);
                        TEncounterProcedure encproc = (TEncounterProcedure)orderPrice_table.getValueAt(row, 1);
                        if(!encproc.getPaymentStatus().equalsIgnoreCase("PAID")){
                        Double price = encproc.getProcedure().getProcedurePrice();
                        totalPrice_textbox.setText(String.valueOf(Double.valueOf(totalPrice_textbox.getText())+price));
                        duePrice_textbox.setText(String.valueOf(Double.valueOf(totalPrice_textbox.getText())-Double.valueOf(paidPrice_textbox.getText())));
                        adjustment_textbox.setText(String.valueOf(Double.parseDouble(totalPrice_textbox.getText())-Double.parseDouble(paidPrice_textbox.getText())-Double.parseDouble(duePrice_textbox.getText())));
                        }
                    }else{
                        orderPrice_table.setValueAt(false, row, 0);
                        TEncounterProcedure encproc = (TEncounterProcedure)orderPrice_table.getValueAt(row, 1);
                        if(!encproc.getPaymentStatus().equalsIgnoreCase("PAID")){
                        Double price = encproc.getProcedure().getProcedurePrice();
                        totalPrice_textbox.setText(String.valueOf(Double.valueOf(totalPrice_textbox.getText())-price));
                        duePrice_textbox.setText(String.valueOf(Double.valueOf(totalPrice_textbox.getText())-Double.valueOf(paidPrice_textbox.getText())));
                        adjustment_textbox.setText(String.valueOf(Double.parseDouble(totalPrice_textbox.getText())-Double.parseDouble(paidPrice_textbox.getText())-Double.parseDouble(duePrice_textbox.getText())));
                        }
                }
            }
            
        }
    }//GEN-LAST:event_orderPrice_tableMouseClicked

    /**
     * @param args the command line arguments
     
    public static void main(String args[]) {
        /* Set the Nimbus look and feel 
        //<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(LabReceiptDialog1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(LabReceiptDialog1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(LabReceiptDialog1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(LabReceiptDialog1.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() {
                LabReceiptDialog1 dialog = new LabReceiptDialog1(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 javax.swing.JLabel addresslabel;
    private javax.swing.JTextField adjustment_textbox;
    private javax.swing.JLabel agelabel;
    private javax.swing.JTextArea comment_taxtArea;
    private javax.swing.JLabel contactnumberlabel;
    private javax.swing.JLabel doblabel;
    private javax.swing.JTextField duePrice_textbox;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel mandatoryStar_label;
    private javax.swing.JLabel namelabel;
    private javax.swing.JTable orderPrice_table;
    private javax.swing.JTextField paidPrice_textbox;
    private javax.swing.JLabel patientidlabel;
    private javax.swing.JTextField receivedBy_textbox;
    private javax.swing.JTextField receivedNumber_textbox;
    private javax.swing.JButton save_button;
    private javax.swing.JLabel sexlabel;
    private javax.swing.JLabel star_label;
    private javax.swing.JTextField totalPrice_textbox;
    // End of variables declaration//GEN-END:variables
    private TPatient patientinfo;
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-YYYY");
    private LabReceiptController labReceiptController;
    private TPatLabReceipt labReceipt;
    private Long savedReceiptID;
    private TPatientEncounter encounter;
    private String[] headerString;
    private Vector<Object> addObject;
    
    
    private void populateData(){
        //labReceipt = new TPatLabReceipt();
        patientinfo = new TPatient();
        encounter = new TPatientEncounter();
        labReceiptController=(LabReceiptController)ContextLoading.context.getBean("labReceiptController");
    }
    
    private void showPatientInfo(TPatient patient) {
        this.patientinfo = patient;
        String patientFullName = null;
        if(patientinfo.getPatientMName()!=null){
            patientFullName = Initcap.toInitCap(patientinfo.getPatientFName())+" "+Initcap.toInitCap(patientinfo.getPatientMName())+" "+Initcap.toInitCap(patientinfo.getPatientLName());
        }else if(patientinfo.getPatientMName()==null){
            patientFullName = Initcap.toInitCap(patientinfo.getPatientFName())+" "+Initcap.toInitCap(patientinfo.getPatientLName());
        }
        namelabel.setText(patientFullName);
        doblabel.setText(sdf.format(patientinfo.getBirthDate()));
        sexlabel.setText(patientinfo.getPatientGender());
        patientidlabel.setText(patientinfo.getPatientId());
        List<String> totalAge = TimeRange.calculateAge(patientinfo.getBirthDate());
        agelabel.setText(totalAge.get(0)+" Yrs "+totalAge.get(1)+" months ");
        if(patientinfo.getPatientHtNumber()!=null){
            contactnumberlabel.setText(String.valueOf(patientinfo.getPatientHtNumber()));
         }else{
                contactnumberlabel.setText("");
         }
         if(patientinfo.getPresentAddress1()!=null){
            addresslabel.setText(String.valueOf(patientinfo.getPresentAddress1()));
         }else{
            addresslabel.setText("");
         }
    }

    private void showSelectedProcedures(TPatientEncounter enc) {
        Double totalPrice = 0d;
        Double paidPrice = 0d;
        String receiptID = null;
        labReceipt = findAvailableLabReceipt();
        if(labReceipt!=null){
                try {
                    List<TEncounterProcedure> encProcList = labReceiptController.getEncounterLabsProcedure(enc);
                    
                    headerString=new String[]{"Select","ID", "Name", "Date", "Price", "Status"};
            
                orderPrice_table.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},headerString) {
                Class[] types = new Class [] {java.lang.Boolean.class,java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class};
                public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
                }
          });
            orderPrice_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            orderPrice_table.getColumnModel().getColumn(1).setPreferredWidth(0);
            orderPrice_table.getColumnModel().getColumn(1).setMinWidth(0);
            orderPrice_table.getColumnModel().getColumn(1).setMaxWidth(0);
            
          orderPrice_table.getColumn("Select").setCellEditor(new DefaultCellEditor(new JCheckBox()));
          //orderPrice_table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
          DefaultTableModel model = (DefaultTableModel)orderPrice_table.getModel();
          for(TEncounterProcedure pat:encProcList){
                    addObject = new Vector<Object>();
                    addObject.add( new Boolean(true));
                    addObject.add(pat);
                    addObject.add(pat.getProcedure().getProcedureName());
                    addObject.add(pat.getOrderDate());
                    addObject.add(pat.getProcedure().getProcedurePrice());
                    addObject.add(pat.getPaymentStatus());
                    model.addRow(addObject);
                    //prescribedTest.add(pat.getProcedure().getId());
                    Double testPrice = pat.getProcedure().getProcedurePrice();
                    totalPrice+=testPrice;
                    if(pat.getPaymentStatus().equalsIgnoreCase("PAID")){
                     paidPrice+=pat.getProcedure().getProcedurePrice();
                    }
                }
             }catch (ProcessingException ex) {
                Logger.getLogger(LabReceiptDialog1.class.getName()).log(Level.SEVERE, null, ex);
             }
            totalPrice_textbox.setText(String.valueOf(totalPrice));
            paidPrice_textbox.setText(String.valueOf(paidPrice));
            duePrice_textbox.setText(String.valueOf(totalPrice-paidPrice));
            try{
                receiptID = labReceiptController.getReceiptId();
            }catch(Exception e){
                throw new HealthCareException("Failed To Get The Max Lab Receipt Id");
            }
            receivedNumber_textbox.setText(receiptID);
            
            //receivedNumber_textbox.setText(labReceipt.getReceiptNumber());
            adjustment_textbox.setText(String.valueOf(Double.parseDouble(totalPrice_textbox.getText())-Double.parseDouble(paidPrice_textbox.getText())-Double.parseDouble(duePrice_textbox.getText())));
            TAccount useraccount = null;
            Preferences myPrefObj = Preferences.userRoot();
            try{
                useraccount = (TAccount)PreferenceUtil.getObject(myPrefObj, "user");
            }catch(Exception e){
                receivedBy_textbox.setText("");
            }
            receivedBy_textbox.setText(useraccount.getFirstName()+" "+ useraccount.getLastName());
        }else{
            try {
                    List<TEncounterProcedure> encProcList = labReceiptController.getEncounterLabsProcedure(enc);
                    
                    headerString=new String[]{"Select","ID", "Name", "Date", "Price", "Status"};
            
                orderPrice_table.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},headerString) {
                Class[] types = new Class [] {java.lang.Boolean.class,java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class};
                public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
                }
          });
                
            orderPrice_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            orderPrice_table.getColumnModel().getColumn(1).setPreferredWidth(0);
            orderPrice_table.getColumnModel().getColumn(1).setMinWidth(0);
            orderPrice_table.getColumnModel().getColumn(1).setMaxWidth(0);
                
          orderPrice_table.getColumn("Select").setCellEditor(new DefaultCellEditor(new JCheckBox()));
          //orderPrice_table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
          DefaultTableModel model = (DefaultTableModel)orderPrice_table.getModel();
          for(TEncounterProcedure pat:encProcList){
                    addObject = new Vector<Object>();
                    addObject.add( new Boolean(true));
                    addObject.add(pat);
                    addObject.add(pat.getProcedure().getProcedureName());
                    addObject.add(pat.getOrderDate());
                    addObject.add(pat.getProcedure().getProcedurePrice());
                    addObject.add(pat.getPaymentStatus());
                    model.addRow(addObject);
                    //prescribedTest.add(pat.getProcedure().getId());
                    Double testPrice = pat.getProcedure().getProcedurePrice();
                    totalPrice+=testPrice;
                    if(pat.getPaymentStatus().equalsIgnoreCase("PAID")){
                     paidPrice+=pat.getProcedure().getProcedurePrice();
                    }
                }
             }catch (ProcessingException ex) {
                Logger.getLogger(LabReceiptDialog1.class.getName()).log(Level.SEVERE, null, ex);
             }
            totalPrice_textbox.setText(String.valueOf(totalPrice));
            paidPrice_textbox.setText(String.valueOf(paidPrice));
            duePrice_textbox.setText(String.valueOf(totalPrice-paidPrice));
            try{
                receiptID = labReceiptController.getReceiptId();
            }catch(Exception e){
                throw new HealthCareException("Failed To Get The Max Lab Receipt Id");
            }
            receivedNumber_textbox.setText(receiptID);
            adjustment_textbox.setText(String.valueOf(Double.parseDouble(totalPrice_textbox.getText())-Double.parseDouble(paidPrice_textbox.getText())-Double.parseDouble(duePrice_textbox.getText())));
            TAccount useraccount = null;
            Preferences myPrefObj = Preferences.userRoot();
            try{
                useraccount = (TAccount)PreferenceUtil.getObject(myPrefObj, "user");
            }catch(Exception e){
                receivedBy_textbox.setText("");
            }
            receivedBy_textbox.setText(useraccount.getFirstName()+" "+ useraccount.getLastName());
        }

    }

    private boolean validateAmountPaid() {
        boolean valid = true;
        if (this.duePrice_textbox.getText().trim().length() == 0) {
            JOptionPane.showMessageDialog(null, " Lab Paid Amount mandatory");
            duePrice_textbox.requestFocus();
            valid = false;
        }
        else if(!this.duePrice_textbox.getText().matches("^\\d*[\\.]?\\d*$")) {
            JOptionPane.showMessageDialog(null, "Invalid Lab Paid Amount type");
            duePrice_textbox.requestFocus();
            duePrice_textbox.selectAll();
            valid = false;
        }
        return valid;
    }
    
    private boolean validateReceiptSave() {
        boolean valid = true;
        if (Double.parseDouble(adjustment_textbox.getText())!=0) {
            if(comment_taxtArea.getText().length()==0){
                JOptionPane.showMessageDialog(null, "Please Enter a proper reason in comment section.");
                valid = false;
            }
        }
        return valid;
    }
    
    private TPatLabReceipt findAvailableLabReceipt(){
        try{
            return labReceiptController.findAvailableLabReceipt(patientinfo,encounter);
        }catch (ProcessingException ex) {
                Logger.getLogger(LabReceiptDialog1.class.getName()).log(Level.SEVERE, null, ex);
                return null;
        }
        
    }
    
}

Commits for Pharmacy_09_03_18/Dr Gyana ProjectSpace/DrGyanaCommonUtil/src/main/java/com/bestray/healthcarecommonutil/views/LabReceiptDialog1.java

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